0

I cannot get this working in Newtonsoft JSON.net nor could I get this to work in any tester app I tried. I don't know why it's not working. Any variation I try fails. Can someone tell me what I'm doing wrong?

{
  "Issue": {
    "Id": 50170,
    "NodeId": "MD=",
    "Url": "https://api.github.com",
    "HtmlUrl": "https://github.com",
    "CommentsUrl": "https://api.github.com",
    "EventsUrl": "https://api.github.com",
    "Number": 105,
    "State": {
      "StringValue": "open",
      "Value": 0
    }
  }
}

Json PATH

$.Issue.State[?(@.Value == 0)]

or

$.Issue[?(@.State.Value == 0)]

It always resolves to an empty set with no matches.

UPDATE

Per the comment below, thanks Michał Ziober, I tried a tester app that uses multiple implementations of Jsonpath. It seems that Jayway and Gatling implementations work, but the others do not. Newtonsoft JSON must be using one of the less capable parsers. :(

Thraka
  • 2,065
  • 19
  • 24
  • Have you tried [jsonpath.herokuapp](http://jsonpath.herokuapp.com/)? Both paths works - returns not empty set. – Michał Ziober Oct 10 '19 at 23:09
  • Thanks. I'm guessing its the fact that goessner doesn't work and it seems to be the most popular in online testers.. :( – Thraka Oct 10 '19 at 23:51

1 Answers1

0

Try this: $.Issue.State[?(@ == 0)]

But why do you query for that property?

Thanh Nguyen
  • 712
  • 6
  • 5
  • I'm trying to expose the JSON file to a config file that can users can input queries in to create conditionals. So my program would load the config, run each query to see if a result shows or not, and if it does, do something. – Thraka Oct 11 '19 at 15:14
  • Thanks for trying to help. I just don't think that JSON.NET can do this. I've defaulted to using JMESPath which seems to work. I'll mark this as correct. Thanks! – Thraka Oct 11 '19 at 16:48