Set Item.vi, insert new parameter to array's element
Not sure whether it is bug or expected behavior, so let me please describe the issue.
I have the following JSON:
{
"Variables": {
"Container": {
"Path": "C:\\trdock_debug.log",
"String": "Configuration String",
"Boolean": true,
"Integer": -5,
"Double": 10.5
},
"Parameters": [
{
"SW": {
"TEST": {
"ENABLE": true
}
}
},
{
"SW": {
"TEST": {
"ENABLE": false
}
}
}
]
}
}
And, I’d like to add new parameter to Variables.Parameters.SW.TEST container (let’s say, that parameter name is “New Parameter”.
So input data to “Set Item.vi” are:
$Path or Item Name = $.Variables.Parameters[0].SW.TEST.New Parameter
JSON to Insert = false
But, error is occurred:
Error 402840 occurred at JSONtext.lvlib:Set Item.vi
Possible reason(s):
Unable to Insert at .Variables.Parameters[0].SW.TEST.New Parameter
When I try to add new parameter to another JSON object outside array, then it works, for example:
$Path or Item Name = $.Variables.Container.New Parameter
JSON to Insert = false
Also, when I set directly “SW” object it works:
$Path or Item Name = $.Variables.Parameters[0].SW
JSON to Insert = false
Or, when I modify existing value “ENABLE” it also works:
$Path or Item Name = $.Variables.Parameters[0].SW.TEST.ENABLE
JSON to Insert = false
Does error occur because of this JSON object is nested within the array please? But on the other hand, if there are different elements in JSON array - string is anyway valid, and it is possible to read/modify parameters from it…
Thank you very much in advance!
Sincerely, Ivan.
Comments (2)
-
repo owner -
repo owner - changed status to resolved
- Log in to comment
Issue traced to “Insertion Point if not found” not wired into subsearch in case of Array. Had to also deal with follow-on issues of in some of the JSONpath parsing functions and Insert logic.