Class 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's JsonSerializable marker interface, such as LDContext and LDValue, 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 any EvaluationDetail<T> instance and it will represent the T value correctly, but when deserializing, you will always get EvaluationDetail<LDValue>.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.fasterxml.jackson.databind.Module module()
      Returns a Jackson Module that defines the correct serialization and deserialization behavior for all LaunchDarkly SDK objects that implement JsonSerializable.
      • Methods inherited from class java.lang.Object

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

      • module

        public static com.fasterxml.jackson.databind.Module module()
        Returns a Jackson Module that defines the correct serialization and deserialization behavior for all LaunchDarkly SDK objects that implement JsonSerializable.
        
             import com.launchdarkly.sdk.json.LDJackson;
             
             ObjectMapper mapper = new ObjectMapper();
             mapper.registerModule(LDJackson.module());
         
        Returns:
        a Module