Convert to XML or JSON data with advanced options
Leave feedback
GroupDocs.Conversion enables converting documents to web data formats such as JSON and XML with advanced customization options through the WebConvertOptions class. This class allows precise control over the conversion process, including specifying the output format via the setFormat method.
Supported Formats
The conversion supports multiple web data formats. To convert documents into JSON or XML, you must set the Format property to either WebFileType.Json or WebFileType.Xml.
Convert CSV to JSON
Below is a code example demonstrating how to convert a CSV file to JSON format using
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.options.convert.WebConvertOptions;importcom.groupdocs.conversion.filetypes.WebFileType;publicclassConvertCsvToJson{publicstaticvoidconvert(){// Initialize the Converter for the input file
try(Converterconverter=newConverter("sample.csv"){// Set up WebConvertOptions with JSON format
WebConvertOptionsoptions=newWebConvertOptions();options.setFormat(WebFileType.Json);// Perform the conversion
converter.convert("converted.json",options);}}publicstaticvoidmain(String[]args){convert();}}
sample.csv is sample file used in this example. Click here to download it.
converted.json is converted JSON file. Click here to download it.
By utilizing these options, you can generate tailored XML or JSON outputs suitable for integration with other systems or APIs.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.