Forum Discussion

harishlean's avatar
harishlean
New Contributor
3 years ago

How to disable FAIL_ON_READING_DUP_TREE_KEY to read json request with duplicates in Ready API?

I am using ready API for automation. One of my response have duplicate attributes, which I could see in Raw response. But, I couldn't transfer any property value from this response because it is read as invalid JSON. How to disable this or any other hack to read a property value? Please suggest. Thanks.

5 Replies

  • richie's avatar
    richie
    Community Hero
    Hey harishlean,

    Just trying to understand.

    When you say the json is invalid, do you mean 'malformed' or 'invalid'?

    Malformed means that the json payload does not conform to standard syntactical wellformed json rules.

    Invalid means that the json payload is invalid relative to either a json schema/swagger/open api definition.

    Im asking to clarify cos they mean two different things and they need different resolutions to sort.

    Are you saying you get a response back, but the json payload is actually malformed json?

    To confirm if its malformed json, copy the payload into here -->

    https://jsonpathfinder.com/

    If the jsonpathfinder website errors, then you have malformed json.

    If the payload is malformed json, then you need a code fix to sort as your endpoint youre hitting should NOT be returning malformed json.

    ReadyAPI/SoapUI uses a json parser to read and recognise the json payload allowing you to assert or grab a value as a property, but the parser will only be able to read wellformed json. It wont work if its malformed.

    Depending on how badly malformed the json is, you can use an event handler to alter the response payload to make it wellformed, but it's a little complicated and depends on how malformed the json payload is.

    If you can publish the json payload so we can see it, we might be able to resolve to allow you to continue working, HOWEVER, your developers will still need to fix the json to make it wellformed anyway, cos this is definitely a defect.

    Cheers,

    Rich
    • harishlean's avatar
      harishlean
      New Contributor
      Hi Riche,
      Thank You for the reply. I have provided a sample response below.
      {
      "product":"book",
      "product":"book",
      "title":"atomic habits"
      }

      Since the attribute "product" is repeated twice, I am getting the mentioned error. It would be great if it can be handled via event handler. I just want to capture the value of "title"

      Get Outlook for Android
      • nmrao's avatar
        nmrao
        Champion Level 3
        You need to first check with your development team or service provider and let them address the issue.