Parse XML response with special characters as valid xml

Not applicable

Hi,

I am receiving soap response as below:

109-xml.png

When I am trying to apply xml to json policy the text between GetQuoteResult node is being considered as string and returning the json as:

{
  "Envelope": {
    "Body": {
      "GetQuoteResponse": {
        "GetQuoteResult": "<StockQuotes><Stock><Symbol>BAC</Symbol><Name>BANK OF AMERICA C</Name></Stock></StockQuotes>"
      }
    }
  }
}

But I want the output as below: Please help me,

{
  "Envelope": {
    "Body": {
      "GetQuoteResponse": {
        "GetQuoteResult": {"StockQuotes":{"Stock":{"Symbol":"BAC","Last":"16.61","Date":"2/13/2015","Time":"4:05pm","Change":"0.06","Open":"16.73","High":"16.79","Low":"16.54}}
      }
    }
  }
}


Solved Solved
1 3 2,361
1 ACCEPTED SOLUTION

akoo
Participant V

Kiran: You're on the right track. We don't have an implicit solution ATM.

View solution in original post

3 REPLIES 3

Not applicable

I have sorted the issue by applying XSL transformation to convert &lt; to < and &gt; to >. Then used Assign Message policy to pass it to Xml To Json policy. However I am looking for an implicit solution.

akoo
Participant V

Kiran: You're on the right track. We don't have an implicit solution ATM.

The XmlToJson policy adds a escape character when the date passed. The xml tag <date>01/12/2017</date> converts as date: 01\/12\/2017. How to avoid the escape character \ during this conversion.