Class JsonUtils

java.lang.Object
co.ankatech.ankasecure.sdk.internal.util.JsonUtils

public final class JsonUtils extends Object
Thread-safe JSON helper with a single, shared ObjectMapper.

The mapper is tuned for human-readable output:

  • Pretty printed (two-space indentation).
  • ISO-8601 date/time serialisation via JavaTimeModule.
  • Timestamps disabled – epoch millis are never written.
  • null exclusion – properties with a null value are silently omitted from the JSON payload to keep the output succinct and to avoid confusion on the consumer side.
Since:
2.1.0
Author:
ANKATech – Security Engineering
  • Method Details

    • toJson

      public static String toJson(Object obj)
      Serialises obj to a JSON string.
      Parameters:
      obj - arbitrary Java object
      Returns:
      canonical JSON representation (never null)
      Throws:
      RuntimeException - if Jackson fails to serialise
    • fromJson

      public static <T> T fromJson(String json, Class<T> type)
      Deserialises the supplied JSON into type.
      Type Parameters:
      T - generic type parameter
      Parameters:
      json - non-null JSON string
      type - target class
      Returns:
      fully populated instance of type
      Throws:
      RuntimeException - if Jackson fails to deserialise