javascript - JSONPath exclude as separate JSON -
i have complex json structure . wan't exclude part , list in 2 buckets. 1 "inclusions" , "exclusions". sample json given below.
{ "item": { "items": [{ "items": [{ "category": "fruit", "item": { "items": [{ "text": "apple" }, { "text": "orange" }, { "text": "grapes" }, { "text": "guava" }], "types": ["value", "value", "value", "value"] }, "type": "or" }, { "category": "fruit", "item": { "text": "pineapple" }, "type": "value" }], "types": ["constraint", "constraint"] }, { "category": "fruit", "item": { "text": "banana" }, "type": "value" }], "types": ["not", "constraint"] }, "type": "and"}
here have category fruits apple,orange ,grapes , guava "or" , pineapple "and" type , banana "not" .once try
item..items[?(@.category='fruit')]..text
it returns me
[ "banana", "apple", "orange", "grapes", "guava", "pineapple"]
but want list
{["apple", "orange", "grapes", "guava", "pineapple" ] },{["banana"]}
is there way in json path of similar structure
that may not answer expected, don't think that's possible jsonpath.
quote jayway/jsonpath
when evaluating path need understand concept of when path definite. path indefinite if contains:
- .. - deep scan operator
- ?() - expression
- [, (, )] - multiple array indexes
indefinite paths returns list (as represented current jsonprovider).
so result list. have closest can get, think.
Comments
Post a Comment