JsonBuffer::parse() doesn't respect nesting limit properly
Created by: Adam5Wu
Thanks for the great library! It saves me so much time and headache. :)
However, I am encountering some difficulties using the parse method for a slightly different purpose. I am trying to write a utility which accepts user input and update json accordingly.
For example:
- Original json:
{ "Test": "abc" }
- User input: Test="def"
- My logic intends to do the following:
- Parse input string and obtain the key
Test
and value"def"
- Use ArduinoJson to parse the value
"def"
into a JsonVariant, make sure user indeed provide a simple string, not a json object or array - Assign the parsed JsonVariant to the original json with the given key
- Parse input string and obtain the key
- Expected new json:
{ "Test": "def" }
However, I am stuck on step 2, because when I call jsonBuffer.parse("\"def\"", 0)
the result always fail.
Reading the document, I suspect the parse method can only accept serialized json object or array, not a simple value, such as boolean, integer, or string. Am i missing anything?
Note that since the utiltiy is general purpose, I cannot know ahead of time which field is which type, I think it is a perfect case to utilize the parser and JsonVariant to achieve this goal and keep the code simple and elegant.