Java tutorial
/* * snackbar 1.0 14 de out de 2016 * * Copyright (c) 2016, hyperCLASS. All rights reserved. hyperCLASS * proprietary/confidential. Use is subject to license terms. */ package br.com.hyperclass.snackbar.restapi.deserializer; import java.io.IOException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import br.com.hyperclass.snackbar.restapi.wrapper.ProductWrapper; /** * * * @author Joo Batista * @version 1.0 14 de out de 2016 */ public class ProductDeserialize extends JsonDeserializer<ProductWrapper> { @Override public ProductWrapper deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new ProductWrapper(node.get("name").asText(), node.get("price").asDouble()); } }