public class JsonUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
JsonUtil.FromJson<T> |
static interface |
JsonUtil.ToJson |
Modifier and Type | Method and Description |
---|---|
static com.fasterxml.jackson.core.JsonFactory |
factory() |
static java.lang.String |
generate(JsonUtil.ToJson toJson,
boolean pretty)
Helper for writing JSON with a JsonGenerator.
|
static com.fasterxml.jackson.databind.JsonNode |
get(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static boolean |
getBool(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.nio.ByteBuffer |
getByteBufferOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static int |
getInt(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static int[] |
getIntArrayOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.List<java.lang.Integer> |
getIntegerList(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Set<java.lang.Integer> |
getIntegerSet(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Set<java.lang.Integer> |
getIntegerSetOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.lang.Integer |
getIntOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static long |
getLong(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.List<java.lang.Long> |
getLongList(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.List<java.lang.Long> |
getLongListOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.lang.Long |
getLongOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Set<java.lang.Long> |
getLongSet(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Set<java.lang.Long> |
getLongSetOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.lang.String |
getString(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.lang.String[] |
getStringArray(com.fasterxml.jackson.databind.JsonNode node) |
static java.util.List<java.lang.String> |
getStringList(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.List<java.lang.String> |
getStringListOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Map<java.lang.String,java.lang.String> |
getStringMap(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.lang.String |
getStringOrNull(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static java.util.Set<java.lang.String> |
getStringSet(java.lang.String property,
com.fasterxml.jackson.databind.JsonNode node) |
static com.fasterxml.jackson.databind.ObjectMapper |
mapper() |
static <T> T |
parse(java.lang.String json,
JsonUtil.FromJson<T> parser)
Helper for parsing JSON from a String.
|
static void |
writeIntegerArray(java.lang.String property,
java.lang.Iterable<java.lang.Integer> items,
com.fasterxml.jackson.core.JsonGenerator gen) |
static void |
writeIntegerFieldIf(boolean condition,
java.lang.String key,
java.lang.Integer value,
com.fasterxml.jackson.core.JsonGenerator generator) |
static void |
writeLongArray(java.lang.String property,
java.lang.Iterable<java.lang.Long> items,
com.fasterxml.jackson.core.JsonGenerator gen) |
static void |
writeLongFieldIf(boolean condition,
java.lang.String key,
java.lang.Long value,
com.fasterxml.jackson.core.JsonGenerator generator) |
static void |
writeStringArray(java.lang.String property,
java.lang.Iterable<java.lang.String> items,
com.fasterxml.jackson.core.JsonGenerator gen) |
static void |
writeStringMap(java.lang.String property,
java.util.Map<java.lang.String,java.lang.String> map,
com.fasterxml.jackson.core.JsonGenerator gen) |
public static com.fasterxml.jackson.core.JsonFactory factory()
public static com.fasterxml.jackson.databind.ObjectMapper mapper()
public static java.lang.String generate(JsonUtil.ToJson toJson, boolean pretty)
toJson
- a function to produce JSON using a JsonGeneratorpretty
- whether to pretty-print JSON for readabilitypublic static <T> T parse(java.lang.String json, JsonUtil.FromJson<T> parser)
T
- type of objects created by the parserjson
- a JSON stringparser
- a function that converts a JsonNode to a Java objectpublic static com.fasterxml.jackson.databind.JsonNode get(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static int getInt(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.lang.Integer getIntOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.lang.Long getLongOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static long getLong(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static boolean getBool(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.lang.String getString(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.lang.String getStringOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.nio.ByteBuffer getByteBufferOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Map<java.lang.String,java.lang.String> getStringMap(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.lang.String[] getStringArray(com.fasterxml.jackson.databind.JsonNode node)
public static java.util.List<java.lang.String> getStringList(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Set<java.lang.String> getStringSet(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.List<java.lang.String> getStringListOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static int[] getIntArrayOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.List<java.lang.Integer> getIntegerList(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Set<java.lang.Integer> getIntegerSetOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Set<java.lang.Integer> getIntegerSet(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.List<java.lang.Long> getLongList(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.List<java.lang.Long> getLongListOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Set<java.lang.Long> getLongSetOrNull(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static java.util.Set<java.lang.Long> getLongSet(java.lang.String property, com.fasterxml.jackson.databind.JsonNode node)
public static void writeIntegerFieldIf(boolean condition, java.lang.String key, java.lang.Integer value, com.fasterxml.jackson.core.JsonGenerator generator) throws java.io.IOException
java.io.IOException
public static void writeLongFieldIf(boolean condition, java.lang.String key, java.lang.Long value, com.fasterxml.jackson.core.JsonGenerator generator) throws java.io.IOException
java.io.IOException
public static void writeIntegerArray(java.lang.String property, java.lang.Iterable<java.lang.Integer> items, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
java.io.IOException
public static void writeLongArray(java.lang.String property, java.lang.Iterable<java.lang.Long> items, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
java.io.IOException
public static void writeStringArray(java.lang.String property, java.lang.Iterable<java.lang.String> items, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
java.io.IOException
public static void writeStringMap(java.lang.String property, java.util.Map<java.lang.String,java.lang.String> map, com.fasterxml.jackson.core.JsonGenerator gen) throws java.io.IOException
java.io.IOException