Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Appendix A Advanced Topics : JSON Parse Related Properties

JSON Parse Related Properties
When parsing JSON data to XML data, you can implement the following functions by configuring the JSON Parse related properties:
Adding JSON root
You can configure the com.tibco.plugin.restjson.json2xml.jsonroot property to add the JSON root name. If you do not set the property, <JSON> is used as the default root. This property is only applicable for the Generic schema type.
To add the JSON root:
1.
Navigate to the TIBCO_HOME\designer\version_number\bin directory.
2.
Open the designer.tra file.
3.
Add the com.tibco.plugin.restjson.json2xml.jsonroot property in the file and set the root value.
4.
Example
For example, the input data is shown as follows:
{"product":"REST","name":"json"}
When you set the root name, for example, JsonRootName, the output data is displayed as follows:
<JsonRootName>
  <product>REST</product>
  <name>json</name>
</JsonRootName>
If you do not add this property, or do not assign a value to this property, JSON is used as the default root name.
<JSON>
  <product>REST</product>
  <name>json</name>
</JSON>
Converting the Special Characters to ASCII Code
When you parse the JSON files, the special character is ignored by default. If you want to convert the special characters to ASCII code, you can configure the com.tibco.plugin.restjson.json2xml.specialIgnored property. This property is applicable for the Generic and the XSD schema types.
To convert the special characters to ASCII code:
1.
Navigate to the TIBCO_HOME\designer\version_number\bin directory.
2.
Open the designer.tra file.
3.
Add the com.tibco.plugin.restjson.json2xml.specialIgnored property in the file and set its value to false.
4.
Example
For example, the input data is shown as follows:
{"Product":{"Nam$e":"REST"}}
If you do not add this property or set the value to true, the output data is displayed as follows:
<Product>
  <Name>REST</Name>
</Product>
If set the value to false, the output is displayed as follows:
<Product>
  <Nam_-36-_e>REST</Nam_-36-_e>
</Product>
Preferring Namespace from Schema Using StAXON
You can configure the com.tibco.plugin.restjson.json2xml.preferNamespaceFromSchema Boolean property to prefer namespace from schema. If you do not set this property to true, the default value is false.
To prefer namespace from schema using StAXON:
1.
Navigate to the TIBCO_HOME\designer\version_number\bin directory.
2.
Open the designer.tra file.
3.
Add the com.tibco.plugin.restjson.json2xml.preferNamespaceFromSchema property in the file and set the boolean value.
4.
Example
For example, the input data is shown as follows:
{"user_cred": {"user_name": "ab12345", "user_password": "45678"}}
Output editor root element: ’user_root’
Default namespace from schema: http://www.tibco.com/schemas/TestStaxon/Schema.xsd
When property com.tibco.plugin.restjson.json2xml.preferNamespaceFromSchema is set to true, the output data is displayed as follows:
<user_root xmlns = "http://www.tibco.com/schemas/TestStaxon/Schema.xsd">
  <user_cred>
    <user_name>ab12345</user_name>
    <user_password>45678</user_password>
  </user_cred>
</user_root>
When property com.tibco.plugin.restjson.json2xml.preferNamespaceFromSchema is set to false, the output data is displayed as follows:
<user_root>
  <user_cred>
    <user_name>ab12345</user_name>
    <user_password>45678</user_password>
  </user_cred>
</user_root>
 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved