Added json support.

r1192 | ffr | 2006-10-26 10:59:03 +1000 (Thu, 26 Oct 2006) | 2 lines
This commit is contained in:
Ferdi Franceschini
2006-10-26 10:59:03 +10:00
committed by Douglas Clowes
parent b22211eaf7
commit c9408a9b45
2 changed files with 84 additions and 22 deletions

View File

@@ -632,7 +632,10 @@ struct json_object *mkJSON_Object(SConnection *pCon, char *pBuffer, int iOut)
json_object_object_add(msg_json, "flag", json_object_new_string(pCode[iOut]));
break;
}
if (iOut == eStatus || iOut == eError || iOut == eWarning) {
if (iOut == eValue || iOut == eEvent) {
tmp_json = json_tokener_parse(pBuffer);
if (is_error(msg_json)) { linenum = __LINE__; goto reporterr; }
} else {
/* Strip \r and \n */
for (pBufferFrom=pBufferTo=pBuffer; ; pBufferFrom++) {
if (*pBufferFrom == '\r' || *pBufferFrom == '\n')
@@ -644,9 +647,6 @@ struct json_object *mkJSON_Object(SConnection *pCon, char *pBuffer, int iOut)
}
tmp_json = json_object_new_string(pBuffer);
if (is_error(msg_json)) { linenum = __LINE__; goto reporterr; }
} else {
tmp_json = json_tokener_parse(pBuffer);
if (is_error(msg_json)) { linenum = __LINE__; goto reporterr; }
}
json_object_object_add(msg_json, "data", tmp_json);
return msg_json;