Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary Error with Additional Comma #1989

Closed
qwerty13 opened this issue Nov 1, 2023 · 1 comment
Closed

Unnecessary Error with Additional Comma #1989

qwerty13 opened this issue Nov 1, 2023 · 1 comment
Labels

Comments

@qwerty13
Copy link

qwerty13 commented Nov 1, 2023

Hi,
Thank you for your valuable library.
I was using ArduinoJson to parse an object array similar to this:

"
[
  {\"name\":\"Test 1\", \"value\":700},\
  {\"name\":\"Test 2\", \"value\":500},\
]

I used the parsing sample code from the page 80 of manual and wonderfully saw library said JSON is invalid, but I still had the deserialized objects and array size was working too (albeit 1 more than total objects). After some tests I figured out the problem was additional comma character at the end of objects.
Since it's not really a problem, please change the validator not to have problem at this situation.

@qwerty13 qwerty13 added the bug label Nov 1, 2023
@bblanchon
Copy link
Owner

Hi @qwerty13,

The JSON format doesn't allow trailing commas in arrays and objects, and ArduinoJson stops reading as soon at it finds one.
In your case, the JsonDocument is complete because the error occured at the end of the document, but if you had anything after the array, it would be lost.

I plan on adding support for JSON5, which supports trailing commas (#1687).

Best regards,
Benoit

@bblanchon bblanchon added question and removed bug labels Nov 2, 2023
@bblanchon bblanchon closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants