Published 2016-08-24
You can use the command-line tool included in the XML ValidatorBuddy package to convert JSON to XML. This allows you to quickly convert any number of JSON files and also to create a scheduled task which runs as a batch process (on your server).
As usual the command-line tool needs a configuration XML to run the conversion. You can specify the folder and any number of file extensions to identify your JSON data. A sample configuration could be like the following one:
<?xml version="1.0" encoding="UTF-8"?>
<batch_settings>
<batch_units>
<log_document path="json_folder_json2xml_log.xml"/>
<options cache_grammars="true" close_logdoc="false" close_xmlspy="false"
error_limit="-1" log_use_xinclude="false" log_valid="true"
notify_finish="false" omit_results="false" omit_time="false"
run_as_test="false" save_logdoc="true" timeout="-1"
use_xmldate_format="true"/>
<batch_unit type="json2xml"
output_folder="C:\Users\Clemens\Documents\JSON2XML_converted">
<folder_settings folder="C:\Users\Clemens\Documents\JSON"
subfolders="true"/>
<file_extensions>
<extension>json</extension>
</file_extensions>
</batch_unit>
</batch_units>
</batch_settings>
Once you have created a configuration XML to set the options and parameters for the JSON to XML conversion you can call the command line tool in the following way:
valbuddy.exe myJSON2XMLconfig.xml
The command line tool will read the configuration XML and runs the batch task. The following line in the XML is important to run a json to xml conversion:
<batch_unit type="json2xml" output_folder="C:\Users\Clemens\Documents\JSON2XML_converted">
If you don’t specify an output folder using the “output_folder” attribute, the resulting XML files are written next to the JSON input documents. Any folder structure from the source directory is also copied to the output folder. You can also set an overwrite attribute like overwrite=”true” or “false” for the <batch_unit> element to overwrite any already existing output documents.
XML ValidatorBuddy is more than just an XML editor. Learn more on clicking the images and links below.
View and edit large XML data - not limited to well-formed input
Learn moreXML editor for Windows ® with syntax-coloring, code folding and many more...
Learn more