Class JsonSerializable

  • All Implemented Interfaces:

    
    public abstract class JsonSerializable
    
                        

    A class that can be serialized to JSON and deserialized from JSON.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String toJson() Serializes the instance to a Json string.
      static String toJsonString(Object object) Serializes an object to a Json string.
      static JsonNode toJsonNode(Object object) Serializes an object to a JsonNode.
      static <T extends JsonSerializable> T fromJsonString(String jsonString, Class<T> clazz) Deserializes a Json string to an object of the given type.
      static <T extends JsonSerializable> T fromJsonNode(JsonNode jsonNode, Class<T> clazz) Deserializes a JsonNode to an object of the given type.
      static JsonNode stringToJsonNode(String string) Converts a Json string to a JsonNode.
      static void setMaxReadLength(int maxReadLength) Overrides the default maximum JSON string length (20MB) for the JSON parser.
      static ObjectMapper objectMapper()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonSerializable

        JsonSerializable()
    • Method Detail

      • toJson

         String toJson()

        Serializes the instance to a Json string.

      • toJsonNode

         static JsonNode toJsonNode(Object object)

        Serializes an object to a JsonNode.

      • setMaxReadLength

         static void setMaxReadLength(int maxReadLength)

        Overrides the default maximum JSON string length (20MB) for the JSON parser.

        Warning: This modifies a global static setting. It will overrides the system property setting via MAX_READ_LENGTH_PROPERTY. This method is not thread-safe.

        Parameters:
        maxReadLength - the new maximum string length in bytes (e.g., 100_000_000 for 100MB).