Package org.apache.iceberg.util
Class JsonUtil
java.lang.Object
org.apache.iceberg.util.JsonUtil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.core.JsonFactoryfactory()static Stringgenerate(JsonUtil.ToJson toJson, boolean pretty) Helper for writing JSON with a JsonGenerator.static com.fasterxml.jackson.databind.JsonNodestatic booleanstatic BooleangetBoolOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static ByteBuffergetByteBufferOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static intstatic int[]getIntArrayOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) getIntegerList(String property, com.fasterxml.jackson.databind.JsonNode node) getIntegerSet(String property, com.fasterxml.jackson.databind.JsonNode node) getIntegerSetOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static IntegergetIntOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static longgetLongList(String property, com.fasterxml.jackson.databind.JsonNode node) getLongListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static LonggetLongOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) getLongSet(String property, com.fasterxml.jackson.databind.JsonNode node) getLongSetOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static <T> List<T> getObjectList(String property, com.fasterxml.jackson.databind.JsonNode node, JsonUtil.FromJson<T> fromJson) static <T> List<T> getObjectListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node, JsonUtil.FromJson<T> fromJson) static Stringstatic String[]getStringArray(com.fasterxml.jackson.databind.JsonNode node) getStringList(String property, com.fasterxml.jackson.databind.JsonNode node) getStringListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) getStringMap(String property, com.fasterxml.jackson.databind.JsonNode node) getStringMapNullableValues(String property, com.fasterxml.jackson.databind.JsonNode node) getStringMapOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) static StringgetStringOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) getStringSet(String property, com.fasterxml.jackson.databind.JsonNode node) static com.fasterxml.jackson.databind.ObjectMappermapper()static <T> Tparse(String json, JsonUtil.FromJson<T> parser) Helper for parsing JSON from a String.static voidwriteIntegerArray(String property, Iterable<Integer> items, com.fasterxml.jackson.core.JsonGenerator gen) static voidwriteIntegerFieldIf(boolean condition, String key, Integer value, com.fasterxml.jackson.core.JsonGenerator generator) static voidwriteIntegerFieldIfPresent(String key, Integer value, com.fasterxml.jackson.core.JsonGenerator generator) static voidwriteLongArray(String property, Iterable<Long> items, com.fasterxml.jackson.core.JsonGenerator gen) static voidwriteLongFieldIf(boolean condition, String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) static voidwriteLongFieldIfPresent(String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) static voidwriteStringArray(String property, Iterable<String> items, com.fasterxml.jackson.core.JsonGenerator gen) static voidwriteStringFieldIfPresent(String key, String value, com.fasterxml.jackson.core.JsonGenerator generator) static voidwriteStringMap(String property, Map<String, String> map, com.fasterxml.jackson.core.JsonGenerator gen)
-
Method Details
-
factory
public static com.fasterxml.jackson.core.JsonFactory factory() -
mapper
public static com.fasterxml.jackson.databind.ObjectMapper mapper() -
generate
Helper for writing JSON with a JsonGenerator.- Parameters:
toJson- a function to produce JSON using a JsonGeneratorpretty- whether to pretty-print JSON for readability- Returns:
- a JSON string produced from the generator
-
parse
Helper for parsing JSON from a String.- Type Parameters:
T- type of objects created by the parser- Parameters:
json- a JSON stringparser- a function that converts a JsonNode to a Java object- Returns:
- the parsed Java object
-
get
public static com.fasterxml.jackson.databind.JsonNode get(String property, com.fasterxml.jackson.databind.JsonNode node) -
getInt
-
getIntOrNull
-
getLongOrNull
-
getLong
-
getBoolOrNull
-
getBool
-
getString
-
getStringOrNull
-
getByteBufferOrNull
public static ByteBuffer getByteBufferOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) -
getStringMapOrNull
-
getStringMap
-
getStringMapNullableValues
-
getStringArray
-
getStringList
-
getStringSet
-
getStringListOrNull
-
getIntArrayOrNull
public static int[] getIntArrayOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) -
getIntegerList
-
getIntegerSetOrNull
-
getIntegerSet
-
getLongList
-
getLongListOrNull
-
getLongSetOrNull
-
getLongSet
-
writeIntegerFieldIf
public static void writeIntegerFieldIf(boolean condition, String key, Integer value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
writeIntegerFieldIfPresent
public static void writeIntegerFieldIfPresent(String key, Integer value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
writeLongFieldIf
public static void writeLongFieldIf(boolean condition, String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
writeLongFieldIfPresent
public static void writeLongFieldIfPresent(String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
writeStringFieldIfPresent
public static void writeStringFieldIfPresent(String key, String value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
getObjectListOrNull
public static <T> List<T> getObjectListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node, JsonUtil.FromJson<T> fromJson) -
getObjectList
public static <T> List<T> getObjectList(String property, com.fasterxml.jackson.databind.JsonNode node, JsonUtil.FromJson<T> fromJson) -
writeIntegerArray
public static void writeIntegerArray(String property, Iterable<Integer> items, com.fasterxml.jackson.core.JsonGenerator gen) throws IOException - Throws:
IOException
-
writeLongArray
public static void writeLongArray(String property, Iterable<Long> items, com.fasterxml.jackson.core.JsonGenerator gen) throws IOException - Throws:
IOException
-
writeStringArray
public static void writeStringArray(String property, Iterable<String> items, com.fasterxml.jackson.core.JsonGenerator gen) throws IOException - Throws:
IOException
-
writeStringMap
public static void writeStringMap(String property, Map<String, String> map, com.fasterxml.jackson.core.JsonGenerator gen) throws IOException- Throws:
IOException
-