Code example for JsonSerializationContext

Methods: serialize

0
	public static class Serializer implements JsonSerializer<CallResultMessage> {
		@Override 
		public JsonElement serialize(CallResultMessage msg, Type arg1,
				JsonSerializationContext context) {
			JsonArray array = new JsonArray();
			array.add(context.serialize(msg.getType().getCode()));
			array.add(context.serialize(msg.callId));
			array.add(msg.payload.getGsonElement());
			return array;
		} 
	} 
 
	public static class Deserializer implements JsonDeserializer<CallResultMessage> {
		@Override 
		public CallResultMessage deserialize(JsonElement element, Type arg1,
				JsonDeserializationContext context) throws JsonParseException {
 
			JsonArray array = element.getAsJsonArray();
			 
			if ( MessageType.fromInteger(array.get(0).getAsInt()) != MessageType.CALLRESULT)