Package tbdex.sdk.protocol.serialization
Object Json
-
- All Implemented Interfaces:
public class JsonA singleton for json serialization/deserialization, shared across the SDK as ObjectMapper instantiation is an expensive operation.
Serialize (stringify)
Deserialize (parse)
val offering = Json.objectMapper.readValue<Offering>(payload) val jsonString = Json.stringify(myObject) val node = Json.parse(payload)
-
-
Field Summary
Fields Modifier and Type Field Description private final ObjectMapperjsonMapperpublic final static JsonINSTANCE
-
Method Summary
Modifier and Type Method Description final Stringstringify(Object obj)Converts a kotlin object to a json string. final ObjectMappergetJsonMapper()The Jackson object mapper instance, shared across the lib. -
-
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.
-
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.
-
-
-
-