Class MessageSerializer

java.lang.Object
com.mparticle.sdk.model.MessageSerializer

public final class MessageSerializer extends Object
Converts messages to JSON and back.
  • Constructor Details

    • MessageSerializer

      public MessageSerializer()
  • Method Details

    • deserialize

      public <T> T deserialize(InputStream inputStream, Class<T> valueType) throws IOException
      Deserializes Java class from JSON.
      Type Parameters:
      T - Java class type
      Parameters:
      inputStream - input stream
      valueType - Java class
      Returns:
      Java class
      Throws:
      IOException - if read fails
    • deserialize

      public <T> T deserialize(String content, Class<T> valueType) throws IOException
      Deserializes Java class from JSON.
      Type Parameters:
      T - Java class type
      Parameters:
      content - content
      valueType - Java class type to deserialize
      Returns:
      Java class
      Throws:
      IOException - if read fails
    • serialize

      public void serialize(OutputStream outputStream, Object value) throws IOException
      Serializes Java class to JSON.
      Parameters:
      outputStream - output stream
      value - Java class to serialize
      Throws:
      IOException - if write fails
    • serializePretty

      public void serializePretty(OutputStream outputStream, Object value) throws IOException
      Serializes Java class to JSON.
      Parameters:
      value - Java class to serialize
      outputStream - output stream
      Throws:
      IOException - if write fails
    • serialize

      public String serialize(Object value) throws IOException
      Serializes Java class to JSON.
      Parameters:
      value - Java class to serialize
      Returns:
      JSON string
      Throws:
      IOException - if write fails