Class LDJackson
- java.lang.Object
-
- com.launchdarkly.sdk.json.LDJackson
-
public class LDJackson extends java.lang.Object
A helper class for interoperability with application code that uses Jackson.An application that wishes to use Jackson to serialize or deserialize classes from the SDK should configure its
ObjectMapper
instance as follows:import com.launchdarkly.sdk.json.LDJackson; ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(LDJackson.module());
This causes Jackson to use the correct JSON representation logic (the same that would be used by
JsonSerialization
) for any types that have the SDK'sJsonSerializable
marker interface, such asLDContext
andLDValue
, regardless of whether they are the top-level object being serialized or are contained in something else such as a collection. It does not affect Jackson's behavior for any other classes.The current implementation is limited in its ability to handle generic types. Currently, the only such type defined by the SDKs is
EvaluationDetail
. You can serialize anyEvaluationDetail<T>
instance and it will represent theT
value correctly, but when deserializing, you will always getEvaluationDetail<LDValue>
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.Module
module()
Returns a JacksonModule
that defines the correct serialization and deserialization behavior for all LaunchDarkly SDK objects that implementJsonSerializable
.
-
-
-
Method Detail
-
module
public static com.fasterxml.jackson.databind.Module module()
Returns a JacksonModule
that defines the correct serialization and deserialization behavior for all LaunchDarkly SDK objects that implementJsonSerializable
.import com.launchdarkly.sdk.json.LDJackson; ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(LDJackson.module());
- Returns:
- a
Module
-
-