Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

markenwerk/java-utils-json-handler-xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XML handler for JSON libraries

Build Status Coverage Status Dependency Status Maven Central Issues MIT License

Overview

This library provides XML related JSON handlers for other JSON processing libraries.

Consult the documentation and the usage description for further information:

Maven

This library is hosted in the Maven Central Repository. You can use it with the following coordinates:

<dependency>
	<groupId>net.markenwerk</groupId>
	<artifactId>utils-json-handler-xml</artifactId>
	<version>2.0.1</version>
</dependency>

Usage

XML document handler

A XmlDocumentJsonHandler is a JsonHandler that creates a XML Document, that represents the described JSON document, using the following rules:

  • A JSON array is represented as a tag with name array.
  • A JSON object is represented as a tag with name object.
  • A JSON object entry is represented as a tag with name entry.
  • The name of a JSON object entry is represented as an attribute of the entry tag with name name.
  • A JSON null is represented as a tag with name null.
  • A JSON boolean is represented as a tag with name boolean.
  • The value of the JSON boolean represented as an attribute of the boolean tag with name value.
  • A JSON number is represented as a tag with name number.
  • The value of the JSON boolean represented as an attribute of the number tag with name value.
  • A JSON string is represented as a tag with name string.
  • The value of the JSON boolean represented as an attribute of the string tag with name value.
// a JsonDocument
JsonDocument document = ...

// returns a xml document  
Document xmlDocument = document.handle(new XmlDocumentJsonHandler());

The returned XML Document for the example.json has the following content:

<?xml version="1.0" encoding="UTF-8"?>
<object>
   <entry name="null">
      <null />
   </entry>
   <entry name="boolean">
      <boolean value="true" />
   </entry>
   <entry name="longValue">
      <number value="-42" />
   </entry>
   <entry name="double">
      <number value="-23.42" />
   </entry>
   <entry name="array">
      <array>
         <string value="foo" />
         <string value="bar" />
      </array>
   </entry>
</object>

About

XML handler for JSON processing libraries for Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages