Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where clause in JSONata

Is there anyway to extract value according to id in an array using JSOnata expression. I wan’t to access Status acccroding to specific tag in following array? As an example Status of id_tag equals"B4A63CDF".

[{"Status":"Expired","id":1,"id_tag":"B4A63CDF","name":"New","expiry":"2022-06-25T11:30:00.000Z","group_m":"Premium","In_transaction":false,"blocked":false},{"Status":"Invalid","id":2,"id_tag":"B5A86CXF","name":"New","expiry":"2022-06-22T11:30:00.000Z","group_m":"Premium","In_transaction":false,"blocked":false}]

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Yeah, this is an example where JSONata is very comfortable to use, you need to filter your array by the id_tag field and then just get the prop you want from the matching item:

$[id_tag="B4A63CDF"].Status

Feel free to play with my solution here: https://stedi.link/i6ntGoX

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading