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:空字符串可能存在 JSON 库错误

Guru**** 2589280 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/999601/cc3235sf-possible-json-lib-bug-with-null-strings

器件型号:CC3235SF

当 json 对象有两个连续的字符串并且第一个字符串为空时,就会出现问题。 库无法解析下一个对象值。

我使用 simplelink_cc32xx_sdk_4_40_00_07随附的 json_app 示例重现了问题。

本示例使用三个非常相似的 json。 但只有两个为键"lk"提供正确的值。

第一个是原始 json、它有一个名为"kp"的密钥、在值为"AB0123456789"的"lk"之前、该值为空。

,\"WM\":0、\"KP\":空、\"lk\":\"AB0123456789\"、--> 查询"lk"返回空值

在第二个 json 中 、"KP"键有一个值、库能够重新取值"lk"。

"wm\":0、\" Kp\":\"AB0123456789\"、\" lk\":\"AB0123456789\"、\" ot\":1}"; 查询"lk"返回 AB0123456789

第三个 json 与第一个 json 相同、但键的顺序发生了变化、"Kp":空、"wm":0、"lk":"AB0671234589"。 因此、当这些字符串一起且第一个值为空时、seccond 值也会等于空。

\"KP\":空、\"WM\":0、\"lk\":\"AB0123456789\"、-->  

空 TestNull ()

   char lk[15]="";
   模板大小= 215;
   templateBuff.fileBuffer =
           "{"act\":boolean、\"id\":int32、\"fn\":string、\"ex\":int32、\"us\":int32、\"nm\":fc、\"st\":int32、\"phid\":string、\"dw\":[int32]、"int32"、"int32"、"intw"、"int32"、"intw"、"int32"、"intw"、"intw"、"int32"、"intw"、"intw"、int32"、intw"、intw"、int32"、intw"、intw"、intw"、int32"、intwm:


   jsonBuffer.fileBuffer =
           "{"act\":true、\"id\":2、\"fn\":\"schrule\"、\"ex\":1766172800、\"us\":7、\"nm\":true、\"st\":1566172800、\"phid\":kp、"dw"、"dw"、"0"、"d80"、"fm:0"、"0"、"fm:0"、"0"、"fm:0"、"0"、"0"、"fm:0"、"0"、"fm"、"0"、"fm:0"、"0"、"fm"、"0"、"0"、0"、"fm"、"0"、"fm:0"、"0"、"0"、"fm:0"、"0"、0"、"fm:0"、0"、0"、


   createTemplate();
   CreateObject();
   pars();
   getStringValue (jsonObjHandle、"\"lk\"、lk);
   destryJsonObject();

   jsonBuffer.fileBuffer =
           "{"act\":true、\"id\":2、\"fn\":\"schrule\"、\"ex\":1766172800、\"us\":7、\"nm\":true、\"st\":1566172800、\"ph\":kp、"dw"、"dw"、"06780"、"fm:0"、"f:0、"d、0"、"d、0"、0"、0"、0"、"f、0"、0"、0"、0"、0"、"f、0"、0"、0"、0"、0"、0"、0"、080、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、0"、
   CreateObject();
   pars();
   getStringValue (jsonObjHandle、"\"lk\"、lk);
   destryJsonObject();
   jsonBuffer.fileBuffer =
           "{"act\":true、\"id\":2、\"fn\":\"schrule\"、\"ex\":1766172800、\"us\":7、\"nm\":true、\"st\":1566172800、\"phid\":kp、"dw"、"dw"、"0"、"dw"、"0:100"、"m:0"、"fm:0"、"0:100"、"fm"、"fm"、"0"、"0"、"fm"、"0"、"fm"、"0"、"fm"、"0"、"fm"、"fm:0"、"0"、"0"、"fm:0"、"0"、"0"、"0"、"fm"、"fm"、"0"、"fm"、"fm"、"0
   CreateObject();
   pars();
   getStringValue (jsonObjHandle、"\"lk\"、lk);
   destryJsonObject();
   destryTemplate();