Class JsonUtil

java.lang.Object
org.apache.iceberg.util.JsonUtil

public class JsonUtil extends Object
  • Method Details

    • factory

      public static com.fasterxml.jackson.core.JsonFactory factory()
    • mapper

      public static com.fasterxml.jackson.databind.ObjectMapper mapper()
    • generate

      public static String generate(JsonUtil.ToJson toJson, boolean pretty)
      Helper for writing JSON with a JsonGenerator.
      Parameters:
      toJson - a function to produce JSON using a JsonGenerator
      pretty - whether to pretty-print JSON for readability
      Returns:
      a JSON string produced from the generator
    • parse

      public static <T> T parse(String json, JsonUtil.FromJson<T> parser)
      Helper for parsing JSON from a String.
      Type Parameters:
      T - type of objects created by the parser
      Parameters:
      json - a JSON string
      parser - 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

      public static int getInt(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getIntOrNull

      public static Integer getIntOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLongOrNull

      public static Long getLongOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLong

      public static long getLong(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getBool

      public static boolean getBool(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getString

      public static String getString(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringOrNull

      public static String getStringOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getByteBufferOrNull

      public static ByteBuffer getByteBufferOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringMap

      public static Map<String,String> getStringMap(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringMapNullableValues

      public static Map<String,String> getStringMapNullableValues(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringArray

      public static String[] getStringArray(com.fasterxml.jackson.databind.JsonNode node)
    • getStringList

      public static List<String> getStringList(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringSet

      public static Set<String> getStringSet(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getStringListOrNull

      public static List<String> getStringListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getIntArrayOrNull

      public static int[] getIntArrayOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getIntegerList

      public static List<Integer> getIntegerList(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getIntegerSetOrNull

      public static Set<Integer> getIntegerSetOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getIntegerSet

      public static Set<Integer> getIntegerSet(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLongList

      public static List<Long> getLongList(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLongListOrNull

      public static List<Long> getLongListOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLongSetOrNull

      public static Set<Long> getLongSetOrNull(String property, com.fasterxml.jackson.databind.JsonNode node)
    • getLongSet

      public static Set<Long> getLongSet(String property, com.fasterxml.jackson.databind.JsonNode node)
    • 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