Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Xpath - Extract element based on other element in the JSON response

Baahubali
Baahubali Posts: 14

I have a JSON response with following structure which is dynamic. I want to extract the account balance to a data bank of specific person eg:John

"Details" : [
{
"AccountBalance" : "6793",
"Person" : "John"
},
{
"AccountBalance" : "3646",
"Person" : "Peter"

Comments

  • jakubiak
    jakubiak Posts: 807 admin

    Try an XPath like the following in your JSON Data Bank: /root/Details/item[Person/text() = 'John']/AccountBalance/text()

  • Baahubali
    Baahubali Posts: 14

    That worked. Thanks a lot!