Skip to content
Emil Forslund edited this page Oct 20, 2016 · 2 revisions

Speedment - Common - JSON

A lightweight JSON serializer and deserializer made with the ambition to reduce complexity for non-performance critical parsing situations. It is not as fast as Gson or feature-rich as Jackson, but very thin and easy to embed in various applications.

This JSON library is designed to deserialize JSON into hierarchical java.util.Map and java.util.List instances.

Serialization

String a = Json.serialize("foo");             // "foo"
String b = Json.serialize(5);                 // 5
String c = Json.serialize(1.0);               // 1.0
String d = Json.serialize(new HashMap<>());   // {}
String e = Json.serialize(new ArrayList<>()); // []
String f = Json.serialize(null);              // null
String g = Json.serialize(false);             // false

Deserialization

String a              = (String) Json.deserialize("\"foo\"");
int b                 = (Integer) Json.deserialize("5");
double c              = (Double) Json.deserialize("1.0");
Map<String, Object> d = (Map<String, Object>) Json.deserialize("{}");
List<Object> e        = (List<Object>) Json.deserialize("[]");
Object f              = (Object) Json.deserialize("null");
boolean g             = (Boolean) Json.deserialize("false");

Maven

To use Json in your own projects, add the following to your pom.xml-file.

<dependency>
    <groupId>com.speedment.common</groupId>
    <artifactId>json</artifactId>
    <version>1.0.1</version>
</dependency>