I work on json path and I study the differents functions of this query language. I tried to use the 'append' function to see how far we can go with it and here's my case :
{
"book": [{
"category": "reference"
}, {
"category": "fiction"
}
],
"rndarr": ["foo", 10]
}
Here's my goal : I want to retrieve all book array and add to this array another array, so I tried this : $.book.append(["foo",10])
and it returned me this :
[
{
"category": "reference"
},
{
"category": "fiction"
},
"foo"
]
As you can see the 10
completly disappear, and here's another weird behavior : when I run this : $.book.append([10])
it returns this :
[
{
"category": "reference"
},
{
"category": "fiction"
},
"10]"
]
To makes things clear my expected output should normally be this (for the first problem) :
[
{
"category": "reference"
},
{
"category": "fiction"
},
["foo", 10]
]
After all of this I tried to make a trick. I tried to call an array that already exist rndarr
and it works : $.book.append($.rndarr)
this return the expected output
[
{
"category": "reference"
},
{
"category": "fiction"
},
[
"foo",
10
]
]
So my question is : Is it possible to write in an hard-coded way a jsonpath that use append function with an array ?