Arun Lal
Arun Lal

Reputation: 59

WSO2 Converts embedded XML to JSON in Payload

I embed an XML into a JSON for the field details and wso2 converts it to JSON. How can I resolve this?

<payloadFactory media-type="json">
  <format>{
    "Customer": {
        "name": "$1",
        "details": "$2"
       }
  }</format>
  <args>
     <arg evaluator="xml" expression="get-property('name')"/>
     <arg evaluator="xml" expression="get-property('detail')"/>
  </args>
</payloadFactory>

Output

{
    "Customer": {
        "name": "Adam",
        "details": "{"id": "123"}"
    }
}

expected

{
    "Customer": {
        "name": "Adam",
        "details": "<id>123</id>"
    }
}

Upvotes: 1

Views: 305

Answers (1)

ycr
ycr

Reputation: 14604

You can simply add the flag literal="true" in the PLFactory args.

<payloadFactory media-type="json">
  <format>{
    "Customer": {
        "name": "$1",
        "details": "$2"
       }
  }</format>
  <args>
     <arg evaluator="xml" expression="get-property('name')"/>
     <arg evaluator="xml" expression="get-property('detail') literal="true" />
  </args>
</payloadFactory>

Upvotes: 2

Related Questions