Other Parts Discussed in Thread: CC2640
Dear TI support,
When parsing jsons in wich one of the values is null, the subsequent values all get nullified. I think this is a bug in the library, probably the same applies for others SDKs of the family. I have found no mention to this in the forums or the release notes for the 5.xx release of the SDK, nor the CC2640 SDK, and so on...
To look at the issue, just parse a json and then build it back to text, as in the next two examples:
INPUT: {"key1":[null, "value12", "value13"], "key3":"value3", "key4":"value4", "key5":"value5"}
OUTPUT: {"key1" : [null , null , null] , "key3" : "value3" , "key4" : "value4"}
INPUT: {"key1":["value11", "value12", "value13"], "key2": null, "key3":"value3", "key4":"value4", "key5":"value5"}
OUTPUT: {"key1" : ["value11" , "value12" , "value13"] , "key2" : null , "key3" : null , "key4" : null}
As you can see, the values in the array become nullified in the output in the first case, and the variables coming after key2 also get nullified in the second case.
Trying to use the Json_getValue function also show that the value is null.
The input/output is processed with the following code snippet:
#define TEMPLATE\
"{"\
"\"key1\":[string],"\
"\"key2\":string,"\
"\"key3\":string,"\
"\"key4\":string,"\
"}"
char text[512]; /* Fill this buffer with the test strings correctly escaped */
int max = 512;
Json_Handle jsonTemplate;
Json_Handle jsonObject;
retVal = Json_createTemplate(&jsonTemplate, TEMPLATE, strlen(TEMPLATE));
retVal = Json_createObject(&jsonObject, jsonTemplate, 0);
retVal = Json_parse(jsonObject, text, strlen(text));
retVal = Json_build(jsonObject, text, &max);
The retVal for all of the functions calls is always 0 (JSON_RC__OK)