jsonpath

How to filter a non-array in JsonPath

你离开我真会死。 提交于 2019-12-12 17:10:01
问题 Using the following JSON (from http://jsonpath.com): { "firstName": "John", "lastName" : "doe", "age" : 26, "address" : { "streetAddress": "naist street", "city" : "Nara", "postalCode" : "630-0192" }, "phoneNumbers": [ { "type" : "iPhone", "number": "0123-4567-8888" }, { "type" : "home", "number": "0123-4567-8910" } ] } I would like to get the root object only if firstName is John. I have tried these inputs and many other similar ones: $.[?($.firstName == 'John')] $.[?($.'firstName' == 'John'

What's the correct JsonPath expression to search a JSON root object using Newtonsoft.Json.NET?

核能气质少年 提交于 2019-12-12 12:29:36
问题 Most examples deal with the book store example from Stefan Gössner, however I'm struggling to define the correct JsonPath expression for a simple object (no array): { "Id": 1, "Name": "Test" } To check if this json contains Id = 1 . I tried the following expression: $..?[(@.Id == 1]) , but this does find any matches using Json.NET? Also tried Manatee.Json for parsing, and there it seems the jsonpath expression could be like $[?($.Id == 1)] ? 回答1: The path that you posted is not valid. I think

JSONPath or other XPath like utility for JSON/Javascript; or Jquery JSON

眉间皱痕 提交于 2019-12-12 07:10:07
问题 I have been looking at JSONPath and though it seems pretty well done, I wonder if anyone has worked with it and can comment on its usability, or can recommend alternatives? What would be really slick is if there was a plugin for JQuery that did something like this. I have been searching the plugins and coming up empty handed. Anyway, before I spend time getting to know JSONPath (which has some aspects I am not keen on), or before I reinvent wheels, I thought I'd see if anyone had an angle on

Filtering out keys from a JavaScript object

旧时模样 提交于 2019-12-12 03:18:35
问题 I have a JavaScript object in the below format { "Node1": [ { "Node2": "node2detail1", "Node3": "node3detail1", "Node4": [ "node4detail1", ] }, { "Node2": "node2detail2", "Node3": "node3detail2", "Node4": [ "node4detail2", ] }, { "Node2": "node2detail3", "Node3": "node3detail3", "Node4": [ "node4detail3", ] } ]} Is it possible to write an jsonpath expression which would result in a JavaScript object in the following format? The intention is to filter by keys. { "Node1": [ { "Node2":

Jayway JSONPath

送分小仙女□ 提交于 2019-12-11 23:57:39
问题 I am using a library which in turn is using Jayway JSONPath. I'm properly referencing a jsonpath $.location.city for the following JSON file. { "venue": { "latitude": "51.0500000", "longitude": "3.7166700" }, "location": { "continent": " EU", "country": "BE", "city": "Brussels" } } But I am getting the error "InvalidPathException com.jayway.jsonpath.PathNotFoundException: Missing property in path $['location']for $.location.city" . Is there any problem with the JSON path ? 来源: https:/

How to select JToken based on multiple name candidates in JSONPath?

社会主义新天地 提交于 2019-12-11 23:16:26
问题 I have a JObject like this: { name1: { value [ ... ] } } It may also be in the form of: { name2: { value [ ... ] } } So I'm trying to use a single JSONPath to select the JArray value out. Is there a way to do something like this? $['name1' or 'name2']['value'] 回答1: Based on the answers to these two SO questions: OR operator in JSONPath? and JsonPath AND Operator on Array, it seems AND and OR operators are not fully supported in JSONPath yet. However, we can use the union operator to

Is it possible to validate a JSONPath expression?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 19:38:44
问题 I want to know if it's possible to validate a JSONPath expression. My JSONPath is $.phoneNumbers[:1].type And my json is as follows: { "phoneNumbers": [ { "type" : "iPhone", "number": "0123-4567-8888" }, { "type" : "home", "number": "0123-4567-8910" } ] } I want to know if I am using the right/valid JSONPath expression. 回答1: You can got to http://jsonpath.curiousconcept.com/ and try it there. Or you can do it in a programming language. Here's how you could do it in Ruby, using the jsonpath

Json.net how to use jsonpath with “$.”

£可爱£侵袭症+ 提交于 2019-12-11 17:57:24
问题 I'm trying to use json.net from json as follows: String JSONString = @"[ { ""category"": ""reference"", ""author"": ""Nigel Rees"", ""title"": ""Sayings of the Century"", ""price"": 8.95 }, { ""category"": ""fiction"", ""author"": ""Still Here"", ""title"": ""Test remove title"", ""price"": 12.99, ""isbn"": ""0-553-21311-3"" } ]"; JObject JSONObject; JSONObject = JObject.Parse(JSONString); String JSONPath = @"$[0].title"; JSONObject.SelectToken(JSONPath); Getting Exception: ST.Acxiom.Test

Expression to filter out elements with empty arrays using `jsonPath`

核能气质少年 提交于 2019-12-11 14:40:32
问题 I have a JSON payload of the form: [ {"id": 1, "list": [1], "name":"one"}, {"id": 2, "list": [1,2], "name":"two"}, {"id": 3, "list": [], "name":"three"} ] And I want to filter out the element from the array the contains an empty "list" property. In other words, I want to discard the element with id=3 and process only the first and second element in my example above. Currently, my filter looks like this: <!-- ne == not equals --> <int:filter id="filter" input-channel="in" output-channel="out"

How to extract substring IN JSON PATH using CAMEL

微笑、不失礼 提交于 2019-12-11 09:59:18
问题 I am trying to configure my routes based on the substring of value from an attribute. For example, I have this Json Attribute: { "carColor": "Red/hatchback" } There are other possibilities such as "Blue/Sedan" and "Black/SUV" etc. I would like to extract the colors only. Meaning I would like to extract the colors before the "/" sign like "Red", "Blue, "Black" etc. This is what I have at the moment: <when> <jsonpath>$.root[?(@.carColor == 'Red')]</jsonpath> <to uri="redCar"/> </when> I know it