Package org.apache.iceberg.util
Class JsonUtil
java.lang.Object
org.apache.iceberg.util.JsonUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.core.JsonFactory
factory()
static String
generate
(JsonUtil.ToJson toJson, boolean pretty) Helper for writing JSON with a JsonGenerator.static com.fasterxml.jackson.databind.JsonNode
static boolean
static ByteBuffer
getByteBufferOrNull
(String property, com.fasterxml.jackson.databind.JsonNode node) static int
static 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 Integer
getIntOrNull
(String property, com.fasterxml.jackson.databind.JsonNode node) static long
getLongList
(String property, com.fasterxml.jackson.databind.JsonNode node) getLongListOrNull
(String property, com.fasterxml.jackson.databind.JsonNode node) static Long
getLongOrNull
(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 String
static 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) static String
getStringOrNull
(String property, com.fasterxml.jackson.databind.JsonNode node) getStringSet
(String property, com.fasterxml.jackson.databind.JsonNode node) static com.fasterxml.jackson.databind.ObjectMapper
mapper()
static <T> T
parse
(String json, JsonUtil.FromJson<T> parser) Helper for parsing JSON from a String.static void
writeIntegerArray
(String property, Iterable<Integer> items, com.fasterxml.jackson.core.JsonGenerator gen) static void
writeIntegerFieldIf
(boolean condition, String key, Integer value, com.fasterxml.jackson.core.JsonGenerator generator) static void
writeLongArray
(String property, Iterable<Long> items, com.fasterxml.jackson.core.JsonGenerator gen) static void
writeLongFieldIf
(boolean condition, String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) static void
writeStringArray
(String property, Iterable<String> items, com.fasterxml.jackson.core.JsonGenerator gen) static void
writeStringMap
(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
-
getBool
-
getString
-
getStringOrNull
-
getByteBufferOrNull
public static ByteBuffer getByteBufferOrNull(String property, com.fasterxml.jackson.databind.JsonNode node) -
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
-
writeLongFieldIf
public static void writeLongFieldIf(boolean condition, String key, Long value, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
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
-