1

I'm trying to dynamically build a JsonPath to find elements in an array based on all their properties. Using a static linq query is not an option because my code needs to work with any array. I'm using Newtonsoft.Json 11.0.2 in my C#.net project.

I'm trying with the JsonPath below but I'm getting an Unexpected character while parsing path indexer: , exception. Seems to work on the jsonpath.curiousconcept.com JsonPath tester using any Flow Communications version.

Any help is greatly appreciated! Thanks!

JsonPath: $.arr[?(@.Amount == '1000'),?(@.Name == 'Item A')]

Json:

{ "arr":[ { "Name":"Item A", "Amount":1000 }, { "Name":"Item B", "Amount":2000 }, { "Name":"Item C", "Amount":3000 }, { "Name":"Item D", "Amount":4000 } ] }

1 Answer 1

2

I assume on the jsonpath.curiousconcept.com the second part is just ignored. Correct JsonPath is:

$.arr[?(@.Amount == 1000 && @.Name == 'Item A')]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Alex! That worked, but I had to remove the quotes from the Amount value. so correct for my example is $.arr[?(@.Amount == 1000 && @.Name == 'Item A')]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.