All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mosip.kernel.masterdata.validator.CustomIntegerDeserializer Maven / Gradle / Ivy

There is a newer version: 1.2.1.0
Show newest version
package io.mosip.kernel.masterdata.validator;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.ObjectMapper;

public class CustomIntegerDeserializer extends JsonDeserializer {

	@Override
	public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
		Integer value = null;
		ObjectMapper mapper = new ObjectMapper();
		mapper.disable(DeserializationFeature.ACCEPT_FLOAT_AS_INT);

		value = mapper.readValue(p, Integer.class);

		return value;
	}

}