Package com.x2j.converter.mgr
Class X2JConversionManager
java.lang.Object
com.x2j.converter.mgr.X2JConversionManager
This class is the place where the actual logic of XML to JSON conversion
resides.
It first looks out for the JSON schema. If present, the code will parse the schema and the incoming XML and then generates the output JSON as per the schema definition.
If not, the default conversion logic is applied wherein every XML node is either a JSON object or JSON Array.
For more information about the JSON schema, please visit: XML-To-JSON Converter.
It first looks out for the JSON schema. If present, the code will parse the schema and the incoming XML and then generates the output JSON as per the schema definition.
If not, the default conversion logic is applied wherein every XML node is either a JSON object or JSON Array.
For more information about the JSON schema, please visit: XML-To-JSON Converter.
-
Method Summary
Modifier and TypeMethodDescriptionstatic X2JConversionManager
Gets the single instance of X2JConversionManager.org.json.JSONObject
processJSONObject
(org.json.JSONObject jsonObj, Element root) This method parses the JSON schema, determines that value/object that needs to be set to a particular key in the final JSON and generates the final JSON as the schema.
It makes multiple other internal method calls to handle: JSON Object (recursive call to itself) JSON Array Stringsorg.json.JSONObject
processJSONObject
(Element root) This method generates the output JSON based on the default conversion logic.
-
Method Details
-
getInstance
Gets the single instance of X2JConversionManager.- Returns:
- instance of X2JConversionManager
-
processJSONObject
This method generates the output JSON based on the default conversion logic.
For more information on the conversion logic, please check the XML.toJSONObject() class here: org.json- Parameters:
root
- the root element of the XML- Returns:
- the resultant JSON object
- Throws:
X2JException
- if any error is thrown during default conversion process
-
processJSONObject
public org.json.JSONObject processJSONObject(org.json.JSONObject jsonObj, Element root) throws X2JException This method parses the JSON schema, determines that value/object that needs to be set to a particular key in the final JSON and generates the final JSON as the schema.
It makes multiple other internal method calls to handle:- JSON Object (recursive call to itself)
- JSON Array
- Strings
- Parameters:
jsonObj
- the JSON schemaroot
- the root element of the XML- Returns:
- the resultant JSON object
- Throws:
X2JException
- if any error is thrown during the conversion process
-