Interface Jsonable

All Known Implementing Classes:
GeolocationOptions, SchemaArticle, SchemaBreadcrumbList, SchemaFAQPage, SchemaOffer, SchemaOrganization, SchemaSoftwareApplication, SchemaType, SchemaWebPage, SchemaWebSite

public interface Jsonable
Interface for objects that can be serialized to and from JSON.

Implement this interface to enable automatic JSON serialization and deserialization of your data classes. Classes implementing Jsonable can be directly added to JsonObject and JsonArray instances, which will automatically call toJsonValue() during serialization.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Initializes this object's state from another Jsonable object.
    void
    Initializes this object's state from a parsed JSON value.
    default void
    Initializes this object's state from a JSON string.
    default String
    Serializes this object to a JSON string.
    Serializes this object to a JsonValue.
  • Method Details

    • initFromJson

      void initFromJson(JsonValue json)
      Initializes this object's state from a parsed JSON value.
      Parameters:
      json - the parsed JSON value.
    • initFromJson

      default void initFromJson(String json)
      Initializes this object's state from a JSON string.
      Parameters:
      json - the JSON string to parse and initialize from.
    • initFromJson

      default void initFromJson(Jsonable json)
      Initializes this object's state from another Jsonable object.
      Parameters:
      json - the Jsonable object to initialize from.
    • toJsonValue

      JsonValue toJsonValue()
      Serializes this object to a JsonValue.
      Returns:
      the JSON representation of this object.
    • toJsonString

      default String toJsonString()
      Serializes this object to a JSON string.
      Returns:
      the JSON string representation.