Puneet Kumar
Puneet Kumar

Reputation: 23

How to extract value from Json where multiple child objects units and only specific value I need to extract

I want to extract tId where "sType= 7"

I've tried to extract all ids from the response and use them randomly, but it doesn't work this way.`

Upvotes: 0

Views: 572

Answers (2)

Rahul Jadhav
Rahul Jadhav

Reputation: 463

There were a lot of errors in JSON. I assumed some tags and fixed it. Refer screenshot below to form your json path

enter image description here

Output enter image description here

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168217

You can use the following JSON Path Expressions in the JSON Extractor:

  1. To extract a random unit id:

    $..units.*.id
    
  2. To extract a random child for the given unit:

    $..units[?(@.id == '${unit}')].children.*.id
    
  3. To extract random content from the child:

    $..children[?(@.id == '${child}')].contents.*.id
    

Demo:

enter image description here

More information:

Upvotes: 0

Related Questions