Service Virtualization

Expand all | Collapse all

Additional "\" getting added while using JSON path filter

Jump to Best Answer
  • 1.  Additional "\" getting added while using JSON path filter

    Posted 09-12-2018 04:12 PM

    Hi All,

             I am trying to store the field value of  JSON response from the REST step which contains SOAP message using  JSON  path filter.The issue is the SOAP message is getting malformed with additional "\" getting added while we are storing in property like as shown below.

     

    <soap:Envelope
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
    soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
    >

     

    <soap:Body>
      <m:GetPriceResponse xmlns:m="https://www.w3schools.com/prices">
        <m:Price>1.90<\/m:Price>
      <\/m:GetPriceResponse>
    <\/soap:Body>

    <\/soap:Envelope>

     

                                                           Thanks,

    Vishwa



  • 2.  Re: Additional "\" getting added while using JSON path filter

    Posted 09-12-2018 04:25 PM

    What version of DevTest are you seeing this issue?  Can you send the expected response.  I can try to reproduce the issue. 



  • 3.  Re: Additional "\" getting added while using JSON path filter

    Posted 09-12-2018 04:33 PM

    Hi,

        Devtest 10.3 and expected is as shown below.

    <soap:Envelope
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
    soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
    >

     

    <soap:Body>
      <m:GetPriceResponse xmlns:m="https://www.w3schools.com/prices">
        <m:Price>1.90</m:Price>
      </m:GetPriceResponse>
    </soap:Body>

    </soap:Envelope>



  • 4.  Re: Additional "\" getting added while using JSON path filter

    Posted 09-12-2018 04:42 PM

    Json Xpath filter  is used on Json responses.  I don't think it works for Soap Response. 

     

     Web sites are available to check the validity of the JSON path expression. One example is   https://jsonpath.curiousconcept.com/. 



  • 5.  Re: Additional "\" getting added while using JSON path filter

    Posted 09-12-2018 05:15 PM

    Hi,

        I have a JSON response as below

    {"field1":"value1",

      "field2":"<soap:Envelope
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
    soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
    >

     

    <soap:Body>
      <m:GetPriceResponse xmlns:m="https://www.w3schools.com/prices">
        <m:Price>1.90</m:Price>
      </m:GetPriceResponse>
    </soap:Body>

    </soap:Envelope>"}



  • 6.  Re: Additional "\" getting added while using JSON path filter
    Best Answer

    Posted 09-12-2018 07:22 PM

    The JSON response is not a valid JSON string - the " character is not escaped.

     

    One option you have is to use the Create property based on surrounding values to save the content between "field2":" & "}

     

    Please refer to https://docops.ca.com/devtest-solutions/10-3/en/reference/filter-descriptions/utility-filters/create-property-based-on-surrounding-values in case you need more information about the same.



  • 7.  Re: Additional "\" getting added while using JSON path filter

    Posted 09-13-2018 10:54 AM

    Hi Prem_Bairoliya,

                                      The JSON response that I am getting from actual application is a valid one may be the example I provided is a bad one and I will try the other option you mentioned above.

                                                                      Thanks,

    Regards,

    LearnNow