Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ Creator & Designer Forum Discussions

DaHu_285096
Level 5
10 likes received 250 replies posted 100 replies posted
Level 5

I have just started using the ultralight cJSON files from Dave Gamble's git ().

GitHub - DaveGamble/cJSON: Ultralightweight JSON parser in ANSI C

I have no issue serializing and parsing strings but there is some issue with the adding numbers to the object. Has anyone else had this issue and know what is happening?

In my code I create several string value pairs no issue like this

cJSON *payload_json = CJSON_CreateObject();

CJSON_AddNumberToObject(payload_json, "range",n);

I have tried numeric variable and fixed number. The object ends up with blank instead of number like { "range":      }

If I use say CJSON_AddStringToObject(payload_json,"result","ok"); I get correct packet {"result":"ok"}

Thanks

0 Likes
1 Solution
Rakshith
Moderator
Moderator 1000 replies posted 750 replies posted 500 replies posted
Moderator

Hi DaHu_285096​,

I have not used the JSON parser that you are referring to. But I found these issues created in the repo that might help you -

  1. Limiting print decimal point
  2. cJSON does not work on non-ASCII systems

Hope this helps,

Thanks and Regards,

Rakshith

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
1 Reply
Rakshith
Moderator
Moderator 1000 replies posted 750 replies posted 500 replies posted
Moderator

Hi DaHu_285096​,

I have not used the JSON parser that you are referring to. But I found these issues created in the repo that might help you -

  1. Limiting print decimal point
  2. cJSON does not work on non-ASCII systems

Hope this helps,

Thanks and Regards,

Rakshith

Thanks and Regards,
Rakshith M B
0 Likes