0
votes

I am facing issue while converting xml to json by using payloadfactory mediator.

the xml structure is containing

<base>tyuä</base>  

and it should be transformed into

"base":"tyuä"

here is the snippet of my code :::

<payloadFactory media-type="json">
            <format>
      {
"base": ""
}
</format>
            <args>
               <arg evaluator="xml" expression="//base/text()"/>
</args>
         </payloadFactory>

But it is giving me as "base":"tyuä". What should be done to resolve it??

1
where do you see the wrong encoding? In the log output or in the message response? (did you try to log the XML before the payload factory if the input is already correct?) - gusto2
actually in wso2logs the xml structure is showing as <base>tyuä</base> which causes the output as "base":"tyuä". But I want output as "base":"tyuä" as per requirement. - Vivek Shah
as well please see what is the REAL message output (response), not just wso2log. The log (console) may screw up encoding of the displayed characters, but the message itself may be ok - gusto2
the output response is getting affected due to this modified data.this should be actual one - Vivek Shah

1 Answers

0
votes

Try adding messageType (with charset=UTF-8) like this, after the payload factory mediator.

<property name="messageType" value="application/json;charset=UTF-8" scope="axis2"/>