Closed drpicox closed 4 years ago
Regarding new proposals, please see #124. Closing as any proposals for significant new features should I think be first drafted as part of this standardization process and then an issue can be filed here to match. However, feel free to comment further as needed.
Note there is currently the sandbox
feature for something similar and this can accept callbacks which can be passed context info, e.g., this test case from test/test.eval.js
:
it('sandbox (with parsing function)', () => {
const expected = [json.store.book];
const result = jsonpath({
json,
sandbox: {
filter (arg) {
return arg.category === 'reference';
}
},
path: "$..[?(filter(@))]", wrap: false
});
assert.deepEqual(result, expected);
});
But your callback would have to make its own jsonpath
call and then filter accordingly.
This is not an issue is a wish. If I find the time, may someday I will implement it by myself.
The idea is the following: Imagine that we have the following JSON (source: https://redux.js.org/recipes/structuring-reducers/normalizing-state-shape/ )
What if I want all the comments of the post1?
What if I want a post given a JS variable and do not worry about escaping?
And #108 is also nice.
Thanks! I'll check JSONata.