Interface JsonService


public interface JsonService
A JSON handling abstraction.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    fromJson(InputStream input, Class<T> clazz)
    Read JSON into a java object.
    <T> T
    fromJson(InputStream input, Type type)
    Read JSON into a java object.
    <T> void
    toJson(T object, OutputStream output)
    Write object data into JSON.
  • Method Details

    • toJson

      <T> void toJson(T object, OutputStream output) throws IOException
      Write object data into JSON.
      Type Parameters:
      T - the object type
      Parameters:
      object - the object to serialize
      output - the output stream
      Throws:
      IOException - when there is a serialization error
    • fromJson

      <T> T fromJson(InputStream input, Class<T> clazz) throws IOException
      Read JSON into a java object.
      Type Parameters:
      T - the object type
      Parameters:
      input - the input stream
      clazz - the object class
      Returns:
      the newly created object
      Throws:
      IOException - when there is a parsing error
    • fromJson

      <T> T fromJson(InputStream input, Type type) throws IOException
      Read JSON into a java object.
      Type Parameters:
      T - the object type
      Parameters:
      input - the input stream
      type - the runtime type of the object
      Returns:
      the newly created object
      Throws:
      IOException - when there is a parsing error