I am trying to use the json inspectors for the first time and I am having some issues with the path inspector. The example on developer.bigfix.com provides a link to the spec for JSONPath, which is a port of xpath for xml.
That page has several examples that all work as expected when I test them at an online tester like jsonquerytool.com. For example, executing $.store.book[*].author
against the test data returns
[
"Nigel Rees",
"Evelyn Waugh",
"Herman Melville",
"J. R. R. Tolkien"
]
However, things are not going so well in QnA. Not sure if I am doing something wrong, or if the path inspector is broken. The main path query using the dollar sign works, but nothing else does.
I can use various workarounds to get the data, but I just wanted to post this to see if anyone else can verify my results.
q: path "$" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
A: {"store":{"bicycle":{"color":"red","price":19.950},"book":[{"author":"Nigel Rees","category":"reference","price":8.950,"title":"Sayings of the Century"},{"author":"Evelyn Waugh","category":"fiction","price":12.990,"title":"Sword of Honour"},{"author":"Herman Melville","category":"fiction","isbn":"0-553-21311-3","price":8.990,"title":"Moby Dick"},{"author":"J. R. R. Tolkien","category":"fiction","isbn":"0-395-19395-8","price":22.990,"title":"The Lord of the Rings"}]}}
T: 0.762 ms
I: singular json value
q: /*the authors of all books in the store*/paths "$.store.book[*].author" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class NotANumeral
q: /*all authors*/paths "$..author" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*all things in store, which are some books and a red bicycle*/paths "$.store.*" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the price of everything in the store*/paths "$.store..price" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the third book*/paths "$..book[2]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the last book in order*/paths "$..book[(@.length-1)]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the last book in order*/paths "$..book[-1:]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the first two books*/paths "$..book[0,1]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*the first two books*/paths "$..book[:2]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*filter all books with isbn number*/paths "$..book[?(@.isbn)]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*filter all books cheapier than 10*/paths "$..book[?(@.price<10)]" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath
q: /*all Elements in XML document. All members of JSON structure*/paths "$..*" of json of file "C:\Temp\BigFix\REST\Testing\store.json"
E: The expression could not be evaluated: class InvalidJSONPath