Giter Club home page Giter Club logo

docconverter's Introduction

DocConverter

DocConverter is a Java library to convert between XML, JSON, CSV and YAML documents. It's a utility class that can be called in a static way.

It takes a string as input in one data format and returns a string into another data format:

String json = DocConverter.convertXmlToJson(String xml) 
String yaml = DocConverter.convertXmltoYaml(String xml)
String csv = DocConverter.convertXmltoCsv(String xml)

String xml = DocConverter.convertJsonToXml(String json)
String yaml = DocConverter.convertJsonToYaml(String json)
String csv = DocConverter.convertJsonToCsv(String json)

String xml = DocConverter.convertYamlToXml(String yaml)
String json = DocConverter.convertYamlToJson(String yaml)
String csv = DocConverter.convertYamlToCsv(String yaml)

String xml = DocConverter.convertCsvToXml(String csv)
String json = DocConverter.convertCsvToJson(String csv)
String yaml = DocConverter.convertCsvToYaml(String csv)

If you have don't have a string as input you can convert several objects first to a string:

DocConverter.convertDocToString(Document doc)
DocConverter.convertFileToString(String path)
DocConverter.convertListToString(List<String> list) 
DocConverter.convertStreamToString(InputStream inputsstream)
DocConverter.convertUriToString(URI uri)	

For example changing a file from XML to JSON:
	
String xml = DocConverter.convertFileToString("C:/example.xml");
String json = DocConverter.convertXmlToJson(xml);
DocConverter.convertStringToFile("C:/example.json",json);

CSV

Conversion to csv expects input in the following flat format:

<rows>
	<row>
		<item1>x</item1>
		<item2>y</item2>
	</row>		
	<row>
		<item1>z</item1>
		<item2>b</item2>
	</row>		
</rows>

Get code

For maven:

<dependency>
  <groupId>io.github.assimbly</groupId>
  <artifactId>docconverter</artifactId>
  <version>1.2.0</version>
</dependency>	

For gradle:

compile 'io.github.assimbly:docconverter:1.2.0'	

Limits

DocConverter is created to make doc conversion of different data formats as easy as possible. It's a generic converter with a simple string representation as input/output.

If you need:

  • Options
  • Type check or validation
  • Flexibility
  • Performance

Please check the following resources:

docconverter's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.