This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235SF: Possible JSON lib bug with null strings

Part Number: CC3235SF

The problem arises when the json object has two consecutive strings and the first is null. The library is unable to parse the next object value.

I reproduced the problem using the json_app example provided with the simplelink_cc32xx_sdk_4_40_00_07.

This example uses three jsons they are very similar. But only two of them give the right value to the key "lk".

The first is the original json, it has a key named "kp" wich value is null before the key "lk" with value "AB0123456789".

,\"wm\":0,\"kp\":null,\"lk\":\"AB0123456789\", --->  the query "lk" returns null

in the second json The "kp" key has a value and the library is able to retun the value of "lk".

\"wm\":0,\"kp\":\"AB0123456789\",\"lk\":\"AB0123456789\",\"ot\":1}";  the query "lk" returns AB0123456789

The third json is identical to the first one but the order of keys is changed, "kp\":null,\"wm\":0,\"lk\":\"AB0123456789\". So it seems that when the strings are together and the first value is null the seccond value is also asumed null.

\"kp\":null,\"wm\":0,\"lk\":\"AB0123456789\", ---> 

void TestNull()
{
    char lk[15] = "";
    templateSize = 215;
    templateBuff.fileBuffer =
            "{\"act\":boolean,\"id\":int32,\"fn\":string,\"ex\":int32,\"us\":int32,\"nm\":boolean,\"st\":int32,\"phid\":string,\"dw\":[int32],\"fc\":[int32],\"fm\":int32,\"pn\":string,\"to\":int32,\"dm\":int32,\"wm\":int32,\"kp\":string,\"lk\":string,\"ot\":int32}";


    jsonBuffer.fileBuffer =
            "{\"act\":true,\"id\":2,\"fn\":\"schrule\",\"ex\":1766172800,\"us\":7,\"nm\":true,\"st\":1566172800,\"phid\":null,\"dw\":[0,1,2,3,4,5,6],\"fc\":[0,1,0],\"fm\":80,\"pn\":null,\"to\":1400,\"dm\":0,\"wm\":0,\"kp\":null,\"lk\":\"AB0123456789\",\"ot\":1}";


    createTemplate();
    createObject();
    parse();
    getStringValue(jsonObjHandle, "\"lk\"", lk);
    destroyJsonObject();

    jsonBuffer.fileBuffer =
            "{\"act\":true,\"id\":2,\"fn\":\"schrule\",\"ex\":1766172800,\"us\":7,\"nm\":true,\"st\":1566172800,\"phid\":null,\"dw\":[0,1,2,3,4,5,6],\"fc\":[0,1,0],\"fm\":80,\"pn\":null,\"to\":1400,\"dm\":0,\"wm\":0,\"kp\":\"AB0123456789\",\"lk\":\"AB0123456789\",\"ot\":1}";
    createObject();
    parse();
    getStringValue(jsonObjHandle, "\"lk\"", lk);
    destroyJsonObject();
    jsonBuffer.fileBuffer =
            "{\"act\":true,\"id\":2,\"fn\":\"schrule\",\"ex\":1766172800,\"us\":7,\"nm\":true,\"st\":1566172800,\"phid\":null,\"dw\":[0,1,2,3,4,5,6],\"fc\":[0,1,0],\"fm\":80,\"pn\":null,\"to\":1400,\"dm\":0,\"kp\":null,\"wm\":0,\"lk\":\"AB0123456789\",\"ot\":1}";
    createObject();
    parse();
    getStringValue(jsonObjHandle, "\"lk\"", lk);
    destroyJsonObject();
    destroyTemplate();
}