Giter Club home page Giter Club logo

Comments (11)

daschfg avatar daschfg commented on June 3, 2024 1

I don't think this is an issue with cJSON.

Just a wild guess: Depending on your STM32 model, maybe this could be related to caching?
Are you sure your data is complete the moment you start parsing it?

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024 1

Hi all,
Thanks for you support and sorry for the late reply.
The issue has been resolved, there is a cJSON pointer that hasn't been freed, so after sometimes the memory leak issue occurs and that leads to the json parse error issue.

from cjson.

mbratch avatar mbratch commented on June 3, 2024

The JSON examples you show look correct. Perhaps there's a hidden non-printable character in the string coming from the NFC NDEF, or perhaps from noise on the communication channel? When you receive the string, before you parse it, can you print it out in hex bytes and check?

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

Thanks for the reply.
The problem is this issue comes at random times, If once it is reproduced I can share those logs

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

Hi,
We got JSON parse error again and we check the hex data and seems it is fine and there are no hidden non printable characters, here is the Log

The text for the record is {"w":"GWiFi","p":"G@dge@n#24it&dp","t":"0,0,26941480,140,170,40,40,100,200,150,29,39,89,45,2,75,75,2"}

The Hex Data of JSON:
{ 7B 22 77 22 3A 22 47 57 69 46 69 22 2C 22 70 22 3A 22 47 40 64 67 65 40 6E 23 32 34 69 74 26 64 70 22 2C 22 74 22 3A 22 30 2C 30 2C 32 36 39 34 31 34 38 30 2C 31 34 30 2C 31 37 30 2C 34 30 2C 34 30 2C 31 30 30 2C 32 30 30 2C 31 35 30 2C 32 39 2C 33 39 2C 38 39 2C 34 35 2C 32 2C 37 35 2C 37 35 2C 32 22 7D }

Error before:0,0,26941480,140,170,40,40,100,200,150,29,39,89,45,2,75,75,2"}

Error in json parsing

from cjson.

mbratch avatar mbratch commented on June 3, 2024

I used the current version of cJSON to parse your string and it did not give an error. The following code prints "JSON ok":

const char *j = "{\"w\":\"GWiFi\",\"p\":\"G@dge@n#24it&dp\",\"t\":\"0,0,26941480,140,170,40,40,100,200,150,29,39,89,45,2,75,75,2\"}";
cJSON * jo = cJSON_Parse(j);

if (jo) {
    printf("JSON ok\n");
else
    printf("JSON invalid\n");

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

While testing we seen that sometimes we are getting JSON parse error at exactly 3rd object being gone to parse.
As you can see on the above logs that I shared the error occurred at object "t" is being gone to extract.

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

For your info Our code is implemented in FreeRTOS on STM32 and the cJSON functions are only called in one thread and not being used in multithread.

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

We are collecting the whole NFC JSON packets before parsing it.

from cjson.

pp-aravind avatar pp-aravind commented on June 3, 2024

Hi,
In our code we put more debug logs in cJSON.c file and these are the error logs that we got when we gave valid json to parse, and we are getting error at exact 3rd object when it goes for parsing. This Json has been working for sometimes but after it is getting unable parse.

The text for the record is {"w":"4SightPatrolWiFi","p":"Backprop1$","t":"0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

The Hex Data of JSON: {7b 22 77 22 3a 22 34 53 69 67 68 74 50 61 74 72 6f 6c 57 69 46 69 22 2c 22 70 22 3a 22 42 61 63 6b 70 72 6f 70 31 24 22 2c 22 74 22 3a 22 30 2c 30
2c 33 37 33 38 30 38 36 36 2c 31 34 30 2c 31 37 30 2c 34 30 2c 34 30 2c 31 30 30 2c 32 30 30 2c 31 30 2c 31 2c 33
39 2c 38 38 2c 34 35 2c 32 2c 37 35 2c 39 31 2c 31 22 7d}

The Hex Data of JSON Length = 106
JSON Text Length = 107
Object JSON
Object JSON Parsing:

"w":"4SightPatrolWiFi","p":"Backprop1$","t":"0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

String JSON output - w
String JSON
String JSON output - 4SightPatrolWiFi

Object JSON Parsing: "p":"Backprop1$","t":"0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

String JSON output - p
String JSON
String JSON output - Backprop1$

.0022681585:INFO :Object JSON Parsing: "t":"0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

String JSON output - t
String JSON
String JSON input_pointer Failed - 0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

Object JSON Failed

cJSON_ParseWithLengthOpts Failed, Item is not NULL
cJSON_ParseWithLengthOpts Failed, Value is not NULL
Error before:0,0,37380866,140,170,40,40,100,200,10,1,39,88,45,2,75,91,1"}

Error
Error in json parsing

from cjson.

rrvirtual avatar rrvirtual commented on June 3, 2024

Hi!
"This Json has been working for sometimes but after it is getting unable parse."

Are you deleting the pointer?
p_json = cJSON_Parse(p_aux_msg);
"cJSON_Delete(p_json)"?

from cjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.