I want to fetch some dynamic id in the below given json file using JSON path finder in npm package.

Sample.json

[{"4787843417861749370": [{"type": "Fast delivery","subtype": "verizon","status": "Dispatched","reason": "null","currency_code": "USD"}],"1502698381711920904": [{"type": "Normal delivery","subtype": "Cisco fiber","status": "Added Cart","reason": "null","currency_code": "USD"}]}]

Output (The below are dynamic id from the above sample. json file):

[4787843417861749370,1502698381711920904]

I have the similar type of the json file which contains n number of dynamic id as JSON sub array. Can someone help me to fetch all these dynamic array from the json file as like above?

1

Best Answer


You can use the jsonpath-plus library and use ~ (for grabbing property names of matching items (as array))

Try the browser demo : https://jsonpath-plus.github.io/JSONPath/demo/

$.*.*~

expression