I have an xml like this.
<jsonObject>
<NotANumber>1234</NotANumber>
<emptyString/>
<boolValue>true</boolValue>
<textMessage>hello</textMessage>
</jsonObject>
I want to convert this to a json.
So, I used below synapse config.
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<jsontransform>
<property name="synapse.commons.enableXmlNullForEmptyElement" value = "true"/>
<property name="synapse.commons.json.output.autoPrimitive" value = "false"/>
</jsontransform>
This is my response.
{
"NotANumber": "1234",
"emptyString": null,
"boolValue": "true",
"textMessage": "hello"
}
Here, "NotANumber" is not a number but a string. "boolValue" is a boolean but not a string. But My response gives "boolValue" as a string.
This is my expected message.
{
"NotANumber": "1234",
"emptyString": null,
"boolValue": true,
"textMessage": "hello"
}
How can I get this response?
Finally I found the answer
<jsontransform>
<property name="synapse.commons.enableXmlNullForEmptyElement" value="true"/>
<property name="synapse.commons.json.output.disableAutoPrimitive.regex" value ="^[1-9]*$"/>
</jsontransform>
This config works for me. I got the response as expected.