extract (print) parent attribute when filtering on child node attribute
I have a json data structure that looks like this:
{ "version": "14",
"data": {
"applications": [
{
"id": 1,
"enabled": true,
"policy": [
]
},
{
"id": 2,
"enabled": true,
"policy": [
{
"type": "Rule",
"id": 5
}
]
}
]
}
I am trying to return the ID of the application when policy id = 5 (or some other int value).
I thought that: $.data.applications[@.policy.*.id is 5].id would work, but i get an empty set [] I also tried: $.data.applications[@.policy..id is 5].id
using "jq" i can do the following:
#cat jsonData.json | jq ‘.data.applications[] | select(.policy[].id == 5) | .id’
13
14
15
16
17
18
19
21
22
23
24
39
Is this query functionality not possible using objectPath?
This is certainly an ObjectPath's bug.
Greetings, Adrian Kalbarczyk
http://kalbarczyk.co
ᐧ
On Mon, Oct 22, 2018 at 1:40 PM LC [email protected] wrote:
I have a json data structure that looks like this:
{ "version": "14", "data": { "applications": [ {
"id": 1, "enabled": true, "policy": [ ] }, { "id": 2, "enabled": true, "policy": [ { "type": "Rule", "id": 5 } ] } ]
}
I am trying to return the ID of the application when policy id = 5 (or some other int value).
I thought that: $.data.applications[@.policy.*.id is 5].id would work, but i get an empty set [] I also tried: $.data.applications[@.policy..id is 5].id
using "jq" i can do the following:
#cat jsonData.json | jq ‘.data.applications[] | select(.policy[].id == 5) | .id’
13 14 15 16 17 18 19 21 22 23 24 39
Is this query functionality not possible using objectPath?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/70, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKycr5q0k2bFyT48-cDzsRm7Y9IXRPGks5una62gaJpZM4XzOtC .