Json.net 带联合的 JsonPath 过滤器

Json.net JsonPath filters with unions

我正在尝试动态构建 JsonPath 以根据元素的所有属性在数组中查找元素。使用静态 linq 查询不是一种选择,因为我的代码需要使用任何数组。我在我的 C#.net 项目中使用 Newtonsoft.Json 11.0.2。

我正在尝试使用下面的 Json 路径,但遇到 Unexpected character while parsing path indexer: , 异常。似乎可以在 jsonpath.curiousconcept.com Json使用任何 Flow Communications 版本的路径测试器上工作。

非常感谢任何帮助!谢谢!

Json路径:$.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 } ] }

我假设 jsonpath.curiousconcept.com 第二部分被忽略了。正确的 JsonPath 是:

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