You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constjju=require('jju');constrawJsonString=`{ "entry1": [ { "path1": "path1" } ], "entry2": "value2"}`constjsonObject=jju.parse(rawJsonString);// add new entries to objectjsonObject["entry3"]={"value2": {"2": true},"value3": {"3": true}}// call the update APIconstnewRawJsonString=jju.update(rawJsonString,jsonObject);// print out to check the valueconsole.log(newRawJsonString);
Now, let's change the rawJsonString in the code, the only difference, is now the entry1 has two elements
constjju=require('jju');constrawJsonString=`{ "entry1": [ { "path1": "path1" }, { "path2": "path2" } ], "entry2": "value2"}`constjsonObject=jju.parse(rawJsonString);// add new entries to objectjsonObject["entry3"]={"value2": {"2": true},"value3": {"3": true}}// call the update APIconstnewRawJsonString=jju.update(rawJsonString,jsonObject);// print out to check the valueconsole.log(newRawJsonString);
Execute it, it will see following output
{
"entry1": [
{
"path1": "path1"
},
{
"path2": "path2"
}
],
"entry2": "value2",
"entry3": {
"value2": {
"2": true, // <--- this tailing comma should not be here
},
"value3": {
"3": true, // <--- this tailing comma should not be here
}, // <--- this tailing comma should not be here
}
}
Which is not correct, you can see there are unexpected tailing commas on the new added entries.
The text was updated successfully, but these errors were encountered:
Suppose we have the following JS code
Execute it, it will see following output
Which is correct.
Now, let's change the
rawJsonString
in the code, the only difference, is now theentry1
has two elementsExecute it, it will see following output
Which is not correct, you can see there are unexpected tailing commas on the new added entries.
The text was updated successfully, but these errors were encountered: