Customer encountered "java.lang.NumberFormatException" error when rendering XML to JSON with character "\"
book
Article ID: KB0135552
calendar_today
Updated On:
Products
Versions
TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON
2.1.0
Description
Description:
When using Render JSON activty to convert XML to JSON, some customer might encounter error like below, In this example, the input XML String contains content "\USA\".
===========================
<ns0:ErrorReport xmlns:ns0="http://www.tibco.com/pe/EngineTypes"><StackTrace>Job-45617 Error in [EP_EX/Processes/PRC_OP_GetProductMessage_EX.process/Format_ JSON_Request] An error occurred in render activity: java.lang.NumberFormatException: For input string: "SA \". at com.tibco.plugin.json.activities.JSONRenderActivity.eval(JSONRenderActivity.java:237) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) </StackTrace><Msg>An error occurred in render activity: java.lang.NumberFormatException: For input string: "SA \".</Msg><FullClass>com.tibco.plugin.json.render.JSONRenderException</FullClass><Class>JSONRenderException</Class><ProcessStack>EP_EX/Processes/PRC_OP_GetProductMessage_EX.process/Format_ JSON_Request</ProcessStack><MsgCode>BW-RESTJSON-100014</MsgCode><Data><ns1:JSONRenderException xmlns:ns1="http://schemas.tibco.com/bw/plugins/xml/5.0/RESTJSONExceptions"><msg>An error occurred in render activity: java.lang.NumberFormatException: For input string: "SA \".</msg><msgCode>BW-RESTJSON-100014</msgCode></ns1:JSONRenderException></Data></ns0:ErrorReport>
===========================
Cause:
This issue is due to in JSON rule, "/" is considered as a valid separator, however "\" is considered as escape character. In REST/JSON plugin 2.0.0, the "\U"or"\u" will be parsed as 16 hexadecimal escape character, which causes the error.
Environment
Product: TIBCO ActiveMatrix BusinessWorks Plug-in for REST and JSON
Version: 2.1.0
OS: All Supported Operating Systems
--------------------
Resolution
This issue has been fixed in the REST JSON plugin 2.0.0 HF01, Customer can use the below options to resolve this issue:
1. Make sure to use the REST JSON Plugin 2.0.0 HF01 and above.
2. Add the below property into designer.tra file in Design time or application.tra file in run time, and then restart the TIBCO Designer or the project runs in TIBCO Administrator: