Interface JsonView<T>

All Known Subinterfaces:
JsonType<T>

public interface JsonView<T>
Represents a subset of properties that can be written as json.

We can use a "view DSL" to dynamically define which properties to include in the json view.

Examples of json view DSL:



   // only include the id and name properties
   (id, name)

   // include billAddress which is a nested type
   (id, name, billingAddress(street, suburb))

   // include billAddress with all it's properties
   (id, name, billingAddress(*))

   (id, name, billingAddress(street, suburb), shippingAddress(*), contacts(email,lastName, firstName))

 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    toJson(T value)
    Return as json string.
    void
    toJson(T value, JsonWriter writer)
    Write to the given writer.
    void
    toJson(T value, JsonOutput output)
    Write to the given output.
    void
    toJson(T value, OutputStream outputStream)
    Write to the given outputStream.
    void
    toJson(T value, Writer writer)
    Write to the given writer.
    byte[]
    toJsonBytes(T value)
    Return the value as json content in bytes form.
    toJsonPretty(T value)
    Return as json string in pretty format.
  • Method Details

    • toJson

      String toJson(T value)
      Return as json string.
    • toJsonPretty

      String toJsonPretty(T value)
      Return as json string in pretty format.
    • toJsonBytes

      byte[] toJsonBytes(T value)
      Return the value as json content in bytes form.
    • toJson

      void toJson(T value, JsonWriter writer)
      Write to the given writer.
    • toJson

      void toJson(T value, Writer writer)
      Write to the given writer.
    • toJson

      void toJson(T value, OutputStream outputStream)
      Write to the given outputStream.
    • toJson

      void toJson(T value, JsonOutput output)
      Write to the given output.