Interface JsonMapper<T>

Type Parameters:
T - the type to define a JSON mapping for

@NullMarked public interface JsonMapper<T>
JsonMapper defines how a class will be converted to and from JsonObjects.
  • Method Details

    • getObjectClass

      Class<T> getObjectClass()
      Returns:
      the Class that will be converted to and from JsonObjects
    • toJson

      JsonObject toJson(T object)
      Converts object of type T into a JsonObject.
      Parameters:
      object - the object to convert
      Returns:
      the JsonObject representing the converted object
    • toJson

      default JsonArray toJson(List<T> list)
      Converts a List of T into a JsonArray.
      Parameters:
      list - the List to convert
      Returns:
      the converted JsonArray
    • toObject

      T toObject(JsonObject jsonObject)
      Converts a JsonObject into an object of type T.
      Parameters:
      jsonObject - the JsonObject to convert
      Returns:
      the converted object of type T
    • toList

      default List<T> toList(JsonArray jsonArray)
      Converts a JsonArray into a List of specified type T. This assumes that each child of jsonArray is a JsonObject and of type T.
      Parameters:
      jsonArray - the JsonArray to convert
      Returns:
      the converted List<T>