public class UtilJackson extends Object
public class Pool {
public int age;
public Pool() {}
}
Here is how you transform it into json back and forth.
// Get a pojo from a string
String json = "{\"age\":2}";
Pool pojo = PojoJsonSerializer.serializer().fromJson(json, Pool.class);
String back = PojoJsonSerializer.serializer().toString(pojo);
Modifier and Type | Class and Description |
---|---|
static class |
UtilJackson.JsonException |
Modifier and Type | Method and Description |
---|---|
static <T> T |
fromJson(String json,
Class<T> classType) |
static <T> T |
fromSettingsMap(ISettingsMap map,
Class<T> classType) |
com.fasterxml.jackson.databind.ObjectMapper |
mapper() |
com.fasterxml.jackson.databind.ObjectWriter |
prettyWriter() |
static UtilJackson |
serializer() |
<T> ISettingsMap |
toSettingsMap(T pojo) |
<T> String |
toString(T pojo) |
com.fasterxml.jackson.databind.ObjectWriter |
writer() |
public static UtilJackson serializer()
public <T> String toString(T pojo)
public <T> ISettingsMap toSettingsMap(T pojo)
public com.fasterxml.jackson.databind.ObjectMapper mapper()
public com.fasterxml.jackson.databind.ObjectWriter writer()
public com.fasterxml.jackson.databind.ObjectWriter prettyWriter()
public static <T> T fromSettingsMap(ISettingsMap map, Class<T> classType)
Copyright © 2014–2023. All rights reserved.