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.

How to extract partial string value from response ?

arunice17
arunice17 Posts: 3

I am getting my response as below format and i want to exact partial string value and send to other call

root
{
"countries" : { "States" : " {\"city": xyz}"
} }

From Above response , i want value "xyz" into my databank and will send this value(xyz) to another API call.

How to do this extraction?

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭
    edited October 2019

    It looks like the value of the "States" property is a JSON string. Are you saying that JSON string contains an encoded JSON object like this?

    {
        "countries" : {
            "States" : "{\"city\": \"xyz\"}"
        }
    }
    

    If so, you would use two JSON Data Banks.

    The first JSON Data Bank would need to extract the value of the "States" property. The extraction would be something like /root/countries/States/text(). Let's also say you name the data bank column for the extraction "Test 1: States".

    The second JSON Data Bank would take the value of the first extraction as input. To do this, simply type "${Test 1: States}" in the text field of the data bank's Input tab. Next, create an extraction for the value of the "city" property. The extraction would be something like /root/city/text(). Let's also say you name the data bank column for the extraction "Test 2: city".

    Your "Test 2: city" data bank column can now be referenced in a later test, wherever you need to use it, like in a REST Client.