Package com.mparticle.sdk.model
Class MessageSerializer
java.lang.Object
com.mparticle.sdk.model.MessageSerializer
Converts messages to JSON and back.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
deserialize
(InputStream inputStream, Class<T> valueType) Deserializes Java class from JSON.<T> T
deserialize
(String content, Class<T> valueType) Deserializes Java class from JSON.void
serialize
(OutputStream outputStream, Object value) Serializes Java class to JSON.Serializes Java class to JSON.void
serializePretty
(OutputStream outputStream, Object value) Serializes Java class to JSON.
-
Constructor Details
-
MessageSerializer
public MessageSerializer()
-
-
Method Details
-
deserialize
Deserializes Java class from JSON.- Type Parameters:
T
- Java class type- Parameters:
inputStream
- input streamvalueType
- Java class- Returns:
- Java class
- Throws:
IOException
- if read fails
-
deserialize
Deserializes Java class from JSON.- Type Parameters:
T
- Java class type- Parameters:
content
- contentvalueType
- Java class type to deserialize- Returns:
- Java class
- Throws:
IOException
- if read fails
-
serialize
Serializes Java class to JSON.- Parameters:
outputStream
- output streamvalue
- Java class to serialize- Throws:
IOException
- if write fails
-
serializePretty
Serializes Java class to JSON.- Parameters:
value
- Java class to serializeoutputStream
- output stream- Throws:
IOException
- if write fails
-
serialize
Serializes Java class to JSON.- Parameters:
value
- Java class to serialize- Returns:
- JSON string
- Throws:
IOException
- if write fails
-