public class JsonSerializer extends Serializer
There is also the strict mode. If strict is OFF: - Unknown enum values will be ignored (as field missing). - Unknown fields will be ignored. - Struct validity will be ignored. If strict more is ON: - Unknown enum values will fail the deserialization. - Unknown fields will fail the deserialization. - Struct validity will fail both serialization and deserialization.
Format is like this:
{
"id":value,
"structId":{ ... },
"listId":[value1,value2],
"mapId":{"id1":value1,"id2":value2}
}
But without formatting spaces. The formatted JSON can be read normally.
Binary fields are base64 encoded.
This format supports 'compact' struct formatting. A compact struct is formatted as a list with fields in order from 1 to N. E.g.:
["tag",5,6.45]is equivalent to:
{"1":"tag","2":5,"3":6.45}
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonSerializer.IdType |
| Modifier and Type | Field and Description |
|---|---|
static String |
JSON_MIME_TYPE |
static String |
MIME_TYPE |
| Constructor and Description |
|---|
JsonSerializer() |
JsonSerializer(boolean strict) |
JsonSerializer(boolean readStrict,
JsonSerializer.IdType idType) |
JsonSerializer(boolean readStrict,
JsonSerializer.IdType idType,
JsonSerializer.IdType enumType,
boolean pretty) |
JsonSerializer(JsonSerializer.IdType idType) |
JsonSerializer(JsonSerializer.IdType idType,
JsonSerializer.IdType enumType) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
binaryProtocol() |
<T extends PMessage<T>> |
deserialize(InputStream input,
PService service) |
<T extends PMessage<T>,TF extends PField> |
deserialize(InputStream input,
PStructDescriptor<T,TF> type) |
String |
mimeType() |
<T extends PMessage<T>> |
serialize(OutputStream output,
PServiceCall<T> call) |
<T extends PMessage<T>> |
serialize(OutputStream output,
T message) |
castpublic static final String MIME_TYPE
public static final String JSON_MIME_TYPE
public JsonSerializer()
public JsonSerializer(boolean strict)
public JsonSerializer(JsonSerializer.IdType idType)
public JsonSerializer(boolean readStrict,
JsonSerializer.IdType idType)
public JsonSerializer(JsonSerializer.IdType idType, JsonSerializer.IdType enumType)
public JsonSerializer(boolean readStrict,
JsonSerializer.IdType idType,
JsonSerializer.IdType enumType,
boolean pretty)
public <T extends PMessage<T>> int serialize(OutputStream output, T message) throws SerializerException
serialize in class SerializerSerializerExceptionpublic <T extends PMessage<T>> int serialize(OutputStream output, PServiceCall<T> call) throws IOException, SerializerException
serialize in class SerializerIOExceptionSerializerExceptionpublic <T extends PMessage<T>,TF extends PField> T deserialize(InputStream input, PStructDescriptor<T,TF> type) throws SerializerException
deserialize in class SerializerSerializerExceptionpublic <T extends PMessage<T>> PServiceCall<T> deserialize(InputStream input, PService service) throws SerializerException
deserialize in class SerializerSerializerExceptionpublic boolean binaryProtocol()
binaryProtocol in class Serializerpublic String mimeType()
mimeType in class SerializerCopyright © 2016. All rights reserved.