Open danieljimeneznz opened 7 years ago
Still investigating. Currently if the key does not exist in the JSON string, it gets inserted correctly with the correct temp variable. Only issue is with the inserted variable now. (Need to seperate if value parameter is a {} or a [] from a "" variable to ensure unnecessary "" are not being added).
Issue fixed to a point where it is usable. Only error currently occurs when an insert is attempted on a parent that does not contain a embedded JSON object,
e.g.
insert("spd", "{}", "3")
insert("req", "120", "3/spd");
Works fine.
but:
insert("spd", "128", "3")
insert("req", "120", "3/spd");
Will have issues.
Closing issue and will open a new one at a later date for the above bug.
Thinking about it further, the above error is actually an illegal operation on a JSON string so a fix is not really required, but it would be good to have an error message or something. i.e. function returns a bool on whether insert was successful or not.
Tested using initial JSON string:
string = "{\"3\":{}}";
First inserting
insert("spd", "{}", "3")
<- This adds an extra opening bracket (and closing bracket).Then inserting
insert("req", "120", "3/spd");
<- This inserts correctly.Then inserting
insert("cur", "123", "3/spd");
<- This causes an issue with location sometimes becoming a very large number. 65135 (etc.)