Class JsonUtils

java.lang.Object
org.apache.gravitino.json.JsonUtils

public class JsonUtils extends Object
Utility class for working with JSON data.
  • Method Details

    • objectMapper

      public static com.fasterxml.jackson.databind.ObjectMapper objectMapper()
      Returns a shared ObjectMapper instance for JSON serialization/deserialization test.

      Note: This instance is intended for testing purposes only. For production use, obtain an ObjectMapper from the following providers:

      • Client side: org.apache.gravitino.client.ObjectMapperProvider
      • Server side: org.apache.gravitino.server.web.ObjectMapperProvider
      Returns:
      the shared ObjectMapper instance for testing.
    • anyFieldMapper

      public static com.fasterxml.jackson.databind.ObjectMapper anyFieldMapper()
      Get the shared AnyFieldMapper instance for JSON serialization/deserialization.
      Returns:
      The ObjectMapper instance.
    • getInt

      public static int getInt(String property, com.fasterxml.jackson.databind.JsonNode node)
      Get an int value from a JSON node property.
      Parameters:
      property - The property name.
      node - The JSON node.
      Returns:
      The int value.
    • getLong

      public static long getLong(String property, com.fasterxml.jackson.databind.JsonNode node)
      Get a long value from a JSON node property.
      Parameters:
      property - The property name.
      node - The JSON node.
      Returns:
      The long value.
    • getString

      public static String getString(String property, com.fasterxml.jackson.databind.JsonNode node)
      Get a string value from a JSON node property.
      Parameters:
      property - The property name.
      node - The JSON node.
      Returns:
      The string value.
      Throws:
      IllegalArgumentException - if the property is missing in the JSON node.