Forum Discussion

Sirisha2020's avatar
Sirisha2020
Contributor
4 years ago

How to use property transfer to fetch specific value in the JSON response.

Hi,

 

I have query on property transfer . I want to retrieve from data TC1 and pass that value as input to TC-2. But when I tried with Property value i am getting entire JSON response.  

For E.g. In TC-1 JSON response has below response data:

"Policy_No" : "xxxx"

href: aaaa/Test/ccc/dddd

 

I want to fetch dddd value and pass that value to TC-2. As I mentioned earlier, Using property value, I am getting entire JSON response as input to TC-2 not dddd.

 

Please let me know how to do this or let me know is there any other way to do this.

 

Thanks.

 

  • richie's avatar
    richie
    Community Hero

    Hey Sirisha2020 

     

    is this ticket related to the other one you raised?

     

    Anyway - you can either try either extracting the whole thing and then try using the split() method to grab the string you want.

     

    The other option I've used before when trying to extract a string within a string is to use a property within a property.

     

    If you have a look here --> https://www.soapui.org/docs/functional-testing/working-with-cdata/  and pay attention to section '3. Property Transfers and CDATA Sections'.  You can I think alter this approach to extract the info you need - at least I've used this approach to extract an href value from a json payload about 3 years ago using this method.

     

    if you don't like the property within a property option, nor the split() method (i find it a little difficult to use) - there is another simpler groovy option - but it will only work if the string up to the dddd is ALWAYS the same length - is it?

     

    ta

     

    Rich

    • Sirisha2020's avatar
      Sirisha2020
      Contributor

      Hi Richie,

       

      I will take a look at the below information and will get back to you. Thanks a lot for your help.  To answer to your first question : Payload is JSON.

       

      Thanks.