JSON path inspector

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

Summoning @AlanM, @Aram, @gearoid or @steve for assistance…

Looking through the code its suggesting something isn’t formed correctly in the JSON (at least according to the code)

I’d probably need your file to take a look at it.

Thanks Alan. The file I used is simply the json from the example here, so you can easily recreate it.

I can reproduce it with 9.5.4 on Mac so I’ll see if I can figure out whats wrong. If I find something I may need you to file a PMR however

1 Like

Hey Alan, I didn’t see anything about this in the 9.5.5 changelist so I’m assuming it may have gotten forgotten…or is it just too low priority?

I spoke with Alan further on this and he suggested I file a PMR. Did so and will report back when I have more info.

So after a lengthy back and forth with IBM in a PMR, I was told that the inspector is “working as expected” and the standard jsonpath syntax would be an “improvement/enhancement”.

While I disagree, there’s not much I can do except file an RFE as they requested. So please vote if you think this should be fixed. I mean improved. :wink:

http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=107201

2 Likes

The IBM RFE appears to have been lost in the transition to HCL.
I have created an HCL IDEA to replace it:
https://bigfix-ideas.hcltechsw.com/ideas/BFP-I-109

3 Likes