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.










share|improve this question
























  • 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















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.










share|improve this question
























  • 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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen