JMESPath - Test values in nested arrays
up vote
0
down vote
favorite
I have an JSON object like this:
Object{9}
[
Keys 1 to 9
]
One of these keys is a array of arrays called restrictions. Like this:
E.G.:
restrictions[3][48]
where 3 means the 3 different places I have,
48 means time instant (intervals of 30 minutes).
And for each one of the 3 places I have, in the 48 time intervals, I have 14 events for place 1, 12 events for place 2 and 6 events for place 3.
So I have something like this:
Place 1 (which means index 0)
restrictions[0][48][14]
Place 2 (which means index 1)
restrictions[1][48][12]
Place 3 (which means index 2)
restrictions[2][48][6]
These events, can be 0 (not occurred) or different to 0, with means they occurred.
So now the question (Sorry for huge description):
I want to use JMESPath to find if any value of any index in the array is different to 0, which means the event happened.
What I really want is the return shows the related position.
I mean, event X happened in place Y in time instant Z, got the idea?
I using https://jsoneditoronline.org/ to apply the filters.
jmespath
add a comment |
up vote
0
down vote
favorite
I have an JSON object like this:
Object{9}
[
Keys 1 to 9
]
One of these keys is a array of arrays called restrictions. Like this:
E.G.:
restrictions[3][48]
where 3 means the 3 different places I have,
48 means time instant (intervals of 30 minutes).
And for each one of the 3 places I have, in the 48 time intervals, I have 14 events for place 1, 12 events for place 2 and 6 events for place 3.
So I have something like this:
Place 1 (which means index 0)
restrictions[0][48][14]
Place 2 (which means index 1)
restrictions[1][48][12]
Place 3 (which means index 2)
restrictions[2][48][6]
These events, can be 0 (not occurred) or different to 0, with means they occurred.
So now the question (Sorry for huge description):
I want to use JMESPath to find if any value of any index in the array is different to 0, which means the event happened.
What I really want is the return shows the related position.
I mean, event X happened in place Y in time instant Z, got the idea?
I using https://jsoneditoronline.org/ to apply the filters.
jmespath
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an JSON object like this:
Object{9}
[
Keys 1 to 9
]
One of these keys is a array of arrays called restrictions. Like this:
E.G.:
restrictions[3][48]
where 3 means the 3 different places I have,
48 means time instant (intervals of 30 minutes).
And for each one of the 3 places I have, in the 48 time intervals, I have 14 events for place 1, 12 events for place 2 and 6 events for place 3.
So I have something like this:
Place 1 (which means index 0)
restrictions[0][48][14]
Place 2 (which means index 1)
restrictions[1][48][12]
Place 3 (which means index 2)
restrictions[2][48][6]
These events, can be 0 (not occurred) or different to 0, with means they occurred.
So now the question (Sorry for huge description):
I want to use JMESPath to find if any value of any index in the array is different to 0, which means the event happened.
What I really want is the return shows the related position.
I mean, event X happened in place Y in time instant Z, got the idea?
I using https://jsoneditoronline.org/ to apply the filters.
jmespath
I have an JSON object like this:
Object{9}
[
Keys 1 to 9
]
One of these keys is a array of arrays called restrictions. Like this:
E.G.:
restrictions[3][48]
where 3 means the 3 different places I have,
48 means time instant (intervals of 30 minutes).
And for each one of the 3 places I have, in the 48 time intervals, I have 14 events for place 1, 12 events for place 2 and 6 events for place 3.
So I have something like this:
Place 1 (which means index 0)
restrictions[0][48][14]
Place 2 (which means index 1)
restrictions[1][48][12]
Place 3 (which means index 2)
restrictions[2][48][6]
These events, can be 0 (not occurred) or different to 0, with means they occurred.
So now the question (Sorry for huge description):
I want to use JMESPath to find if any value of any index in the array is different to 0, which means the event happened.
What I really want is the return shows the related position.
I mean, event X happened in place Y in time instant Z, got the idea?
I using https://jsoneditoronline.org/ to apply the filters.
jmespath
jmespath
edited Nov 20 at 14:51
asked Nov 19 at 19:06
João Victor Guimarães
11
11
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14
add a comment |
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53381088%2fjmespath-test-values-in-nested-arrays%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's a lot easier to answer this sort of question if you give an example of the input and an example of the output you want.
– james.haggerty
Nov 24 at 3:48
My problem was solved using a script in Python. But I would really appreciate if I could to the same with JMESPath in the future. Heres my script. imgur.com/lEMhJYH The return is this: imgur.com/IKYTIOw
– João Victor Guimarães
Nov 25 at 5:14