Introduction

Skaringa is an API for Java, JSON and XML language binding.

It transforms Java objects into JSON or XML documents and back, and can generate XML schema definitions for Java classes.

Typical applications are data exchange, object persistence, object transformation, and driving XML or JavaScript based presentation layers.

Skaringa is designed for speed and simplicity, supporting a wide range of types. Skaringa works with all Plain Old Java Objects (POJOs), it is not limited to special cases, like JavaBeans.

Quick Start

Serialize a Java object into a XML file

Person fred = new Person();

ObjectTransformer trans =
  ObjectTransformerFactory.getInstance().getImplementation();
                
FileOutputStream out = new FileOutputStream("fred.xml");
trans.serialize(fred, new StreamResult(out));
out.close();

Deserialize a XML file into a Java object

FileInputStream in = new FileInputStream("fred.xml");
Person freddy =
  (Person) trans.deserialize(new StreamSource(in));
in.close();

Write the XML schema definition of a Java class into a file

out = new FileOutputStream("Person.xsd");
trans.writeXMLSchema(Person.class, new StreamResult(out));
out.close();

Transform a Java object into another object of different type using XSLT

trans.setPostprocessorInstruction(new StreamSource(
  ClassLoader.getSystemResourceAsStream("Person2OrgMember.xsl")));

OrgMember fredTheMember =
  (OrgMember) trans.transform(fred);

Serialize a Java object into a JSON file

Person fred = new Person();

ObjectTransformer trans =
  ObjectTransformerFactory.getInstance().getImplementation();
      
OutputStream out = new FileOutputStream("fred.js");
trans.serializeToJson(fred, out);
out.close();

Deserialize from a JSON stream into a Java object

FileInputStream in = new FileInputStream("fred.js");
Person freddy =
  (Person) trans.deserializeFromJson(in, Person.class);
in.close();

See the developer guide for a detailed description and examples. Other project activities, like news, download, CVS access, forums, bug tracker, etc., are accessible via the project page at SourceForge.net.