Comments (11)
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.
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.
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.
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.
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.
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.
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.
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.
We are collecting the whole NFC JSON packets before parsing it.
from cjson.
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.
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)
- question on vxworks 6.8 HOT 3
- cJSON_DeleteItemFromArray considers dicts and arrays equally HOT 1
- Cannot Parse JSON HOT 5
- Add a function cJSON_IsEmpty() HOT 4
- Always provide valuestring
- Double Free Vulnerability Discovered in cJSON_Delete Function Through Fuzzing HOT 6
- Fix cmake export to allow cross-compilation with sysroot HOT 1
- Regression on double precision in print_number() when fix a clang compile warning
- A segmentation fault in cJSON_SetValuestring HOT 2
- Can't Install it on PI HOT 2
- cJSON_CreateStringArray and NULL items HOT 4
- Weird Commits HOT 3
- Question: JSON Minifier
- print_number() non guaranteed to be thread safe with floating point numbers
- sorry,delete it
- misc_tests fails on 1.7.18 under Windows HOT 1
- Memory Leak in the cJSON_Free HOT 2
- Bug in print_string_ptr() increment is 4 instead of 5 HOT 2
- Unable to Specify macOS min version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cjson.