{
"Names": [
{
"Name": [
{
"id": "850340277",
"username": "Ajanthan",
"accountLocked": false
}
]
}
]
}
The output with default settings will be like below. YOu can observe that the string passed with numbers have converted to Integer.
{
"Names": [
{
"Name": [
{
"id": 850340277,
"username": "Ajanthan",
"accountLocked": false
}
]
}
]
}
Using adding the property synapse.commons.json.json.output.autoPrimitive=false in <APIM_HOME>/repository/conf/synapse.properties file we can overcome the issue and keep the string as it is. But the boolean values will also be converted to String. You can observe that from the below:
{
"Names": [
{
"Name": [
{
"id": "850340277",
"username": "Ajanthan",
"accountLocked": "false"
}
]
}
]
}
To overcome this problem, the recommended option is to move to JsonStreamBuilder and JsonStreamFormatter combination.
Comment the below:
<messageBuilder contentType="application/json"
class="org.apache.synapse.commons.json.JsonBuilder"/>
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonFormatter"/>
and uncomment the below:
<messageBuilder contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
And now we can get the expected output after the conversion.
{
"Names": [
{
"Name": [
{
"id": "850340277",
"username": "Ajanthan",
"accountLocked": false
}
]
}
]
}
Hope this helps...
Hi,
ReplyDeletesynapse.commons.json.json.output.autoPrimitive=false
This should be corrected as below.
synapse.commons.json.output.autoPrimitive=false
Thanks