{"action":"created","issue":{"url":"https://api.github.com/repos/s3u/JSONPath/issues/75","repository_url":"https://api.github.com/repos/s3u/JSONPath","labels_url":"https://api.github.com/repos/s3u/JSONPath/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/s3u/JSONPath/issues/75/comments","events_url":"https://api.github.com/repos/s3u/JSONPath/issues/75/events","html_url":"https://github.com/s3u/JSONPath/issues/75","id":174966281,"number":75,"title":"is there a \"In\" operator in the JSONPath for arrays.","user":{"login":"dlsagayaraj","id":7427571,"avatar_url":"https://avatars.githubusercontent.com/u/7427571?v=3","gravatar_id":"","url":"https://api.github.com/users/dlsagayaraj","html_url":"https://github.com/dlsagayaraj","followers_url":"https://api.github.com/users/dlsagayaraj/followers","following_url":"https://api.github.com/users/dlsagayaraj/following{/other_user}","gists_url":"https://api.github.com/users/dlsagayaraj/gists{/gist_id}","starred_url":"https://api.github.com/users/dlsagayaraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlsagayaraj/subscriptions","organizations_url":"https://api.github.com/users/dlsagayaraj/orgs","repos_url":"https://api.github.com/users/dlsagayaraj/repos","events_url":"https://api.github.com/users/dlsagayaraj/events{/privacy}","received_events_url":"https://api.github.com/users/dlsagayaraj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-04T19:49:59Z","updated_at":"2016-09-04T20:16:59Z","closed_at":"2016-09-04T20:16:59Z","body":"    var data = {\r\n        grouped_people: {\r\n            'friends': [\r\n                {name: 'Steve', country: ['NZ','US']},\r\n                {name: 'Daniel', country: ['NZ']},\r\n                {name: 'Bob', country: ['US']}\r\n            ],\r\n            'enemies': [\r\n                {name: 'Evil Steve', country: ['NZ','US']}\r\n            ]\r\n        }\r\n    }\r\n\r\ni am trying to get people who have country as \"US\",  which should result in getting me the records of Steve,Bob, and Evil Steve. \r\n\r\nI tried this below query but it gets me only the Bob.  \r\n  \r\nvar values=    JSONPath({json: data, path: \"$..[?(@.country=='US')]\"});\r\n\r\nIs there anything i could use to specify \"in\"/\"has\" operator for an array?\r\nsome thing like below. \r\n\r\nvar values=    JSONPath({json: data, path: \"$..[?('US' in @.country)]\"});\r\n"},"comment":{"url":"https://api.github.com/repos/s3u/JSONPath/issues/comments/244626156","html_url":"https://github.com/s3u/JSONPath/issues/75#issuecomment-244626156","issue_url":"https://api.github.com/repos/s3u/JSONPath/issues/75","id":244626156,"user":{"login":"brettz9","id":20234,"avatar_url":"https://avatars.githubusercontent.com/u/20234?v=3","gravatar_id":"","url":"https://api.github.com/users/brettz9","html_url":"https://github.com/brettz9","followers_url":"https://api.github.com/users/brettz9/followers","following_url":"https://api.github.com/users/brettz9/following{/other_user}","gists_url":"https://api.github.com/users/brettz9/gists{/gist_id}","starred_url":"https://api.github.com/users/brettz9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettz9/subscriptions","organizations_url":"https://api.github.com/users/brettz9/orgs","repos_url":"https://api.github.com/users/brettz9/repos","events_url":"https://api.github.com/users/brettz9/events{/privacy}","received_events_url":"https://api.github.com/users/brettz9/received_events","type":"User","site_admin":false},"created_at":"2016-09-04T20:16:59Z","updated_at":"2016-09-04T20:16:59Z","body":"The content of the filters (e.g. `@.country=='US'`) is going to be evaluated JavaScript (with the `@` replaced). So use JavaScript `indexOf` to test, though making sure that the property exists before acting on it:\r\n\r\n```\r\n$..[?(@.country && @.country.indexOf('US') > -1)]\r\n```\r\n\r\nI'm closing, but feel free to comment further."}}
{"actor":{"display_login":"brettz9"}}