Object Json

  • All Implemented Interfaces:

    
    public class Json
    
                        

    A singleton for json serialization/deserialization, shared across the SDK as ObjectMapper instantiation is an expensive operation.

    val offering = Json.objectMapper.readValue<Offering>(payload)
    
    val jsonString = Json.stringify(myObject)
    
    val node = Json.parse(payload)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String stringify(Object obj) Converts a kotlin object to a json string.
      final <T extends Any> T parse(String payload) Parse a json string into a kotlin object.
      final Map<String, Object> toMap(String $self) Parse a JSON string into a Map.
      final ObjectMapper getJsonMapper() The Jackson object mapper instance, shared across the lib.
      final ObjectReader getObjectReader()
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • stringify

         final String stringify(Object obj)

        Converts a kotlin object to a json string.

        Parameters:
        obj - The object to stringify.
        Returns:

        json string.

      • parse

         final <T extends Any> T parse(String payload)

        Parse a json string into a kotlin object.

        Parameters:
        payload - JSON string to parse
        Returns:

        parsed type T

      • getJsonMapper

         final ObjectMapper getJsonMapper()

        The Jackson object mapper instance, shared across the lib.

        It must be public in order for typed parsing to work as we cannot use reified types for Java interop.