Forum Discussion

aankushpaunikar's avatar
2 years ago
Solved

Property transfer unable to parse json array

I have a below response from which I want to extract original_message_identification.   Response : [ { "batch_id": 23019, "creditor_name": "test123", "debtor_name": "debitor 123", "original_c...
  • Shashavali's avatar
    2 years ago

    Why can't you try in another way - using groovy script to read / parse the response and set the value in the testcase / testsuite / project property and then retrieve. 

     

    Below is the example.

     

    import groovy.json.JsonSlurper
    def res = context.expand('${REST#Response}') --- This steps read the response and store in variable
    log.info res
    def jsonSlurper = new JsonSlurper()
    def object = jsonSlurper.parseText(res)  -- Parse the response 
    String img = object.products[0].images[0]  -- Get value of the attribute using json path
    testRunner.testCase.setPropertyValue("img",img) -- Set the value as test case property
    log.info (testRunner.testCase.getPropertyValue("img")) -- Get the value from the test case property