Find json value when parent changes

I have a json string like this
{"ae578":{"id":"208","item_key":"ae578","name":"","ip":"64.178.232.98","meta":{"3ncbm":"Booked","stxqs":"CB-S-42","7qkpy":"","9p2im":"","oyi0j":"","vjo1z":"","qieme":"","pei27":"","pei27-value":"","4ovfs":"","bkmgr":"","pg72h":"Employees"},"form_id":"5","post_id":"0","user_id":"1","parent_item_id":"0","is_draft":"0","updated_by":"1","created_at":"2022-11-28 15:32:40","updated_at":"2023-03-15 23:59:45"}}

But the next time a run the query I get this

{"2wfk1":{"id":"207","item_key":"2wfk1","name":"","ip":"64.178.232.98","meta":{"3ncbm":"Booked","stxqs":"CB-S-41","7qkpy":"","9p2im":"","oyi0j":"","vjo1z":"","qieme":"","pei27":"","pei27-value":"","4ovfs":"","bkmgr":"","pg72h":"Employees"},"form_id":"5","post_id":"0","user_id":"1","parent_item_id":"0","is_draft":"0","updated_by":"1","created_at":"2022-11-28 15:32:40","updated_at":"2023-03-15 23:59:45"}}

Notice the parent of the first results are ae578 and for the second results the parent is 2wfk1. However the value I need to use for the next op in my scenario is the id field which is always present in the first child under id In the first example it’s 208 and in the 2nd example it’s 207. How do I get the id value to pass onto the next operation even though the parent value changes. The default would be {{1.body.ae578.id}} but that doesn’t work for the second example since ae578 is not longer there.

Thanks for you help.

@wra :raised_hands:

Hi there! I’m an AI that is still learning. It looks like you are trying to figure out how to get the ID value from a JSON string, even when the parent value changes. Can you tell the community more about the scenario you are trying to achieve? We’re here to help!

It often helps to take a camera-viewfinder-duotone screenshot of your scenario along with the relevant module configurations and share-all-duotoneshare the images here so that the community can help.

All of this helps us to get a deeper understanding of the challenge you face. :make:

I showed my example in the orginal post. Can anyone help me?

I hope someone else has a better solution for this, but if you are stuck with this, Please try this solution and see if it works for you.

What you want to do is, Wrap the JSON and then Parse the JSON. In the Parse JSON module, wrap the incoming JSON like this,

{"data" : {"ae578":{"id":"208","item_key":"ae578","name":"","ip":"64.178.232.98","meta":{"3ncbm":"Booked","stxqs":"CB-S-42","7qkpy":"","9p2im":"","oyi0j":"","vjo1z":"","qieme":"","pei27":"","pei27-value":"","4ovfs":"","bkmgr":"","pg72h":"Employees"},"form_id":"5","post_id":"0","user_id":"1","parent_item_id":"0","is_draft":"0","updated_by":"1","created_at":"2022-11-28 15:32:40","updated_at":"2023-03-15 23:59:45"}}}

After which, You can access the id using the following,

{{get(1.data; get(keys(1.data); 1) + ".id")}}

For reference and to test this out, you can use this blueprint as attached.

blueprint (29).json (3.8 KB)

3 Likes