Code example for JsonArray

Methods: getsize

0
		public PublishMessage deserialize(JsonElement element, Type arg1,
				JsonDeserializationContext context) throws JsonParseException {
 
			JsonArray array = element.getAsJsonArray();
 
			if ( MessageType.fromInteger(array.get(0).getAsInt()) != concreteMessageType)
				return null; 
 
			PublishMessage msg = new PublishMessage();
			msg.topicUri = array.get(1).getAsString();
			if ( ! ( array.get(2) instanceof JsonNull ) )
				msg.payload = array.get(2);
			if ( array.size() == 4 ) {
				if ( array.get(3) instanceof JsonPrimitive)
					msg.excludeMe = array.get(3).getAsBoolean();
				else 
					return null; // exclude and eligible are not supported yet 
			} 
			else if ( array.size() == 5 )
				return null; // exclude and eligible are not supported yet 
			return msg;
		} 
	}