package ru.dreamteam.couch.util;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* Helper methods to work with JSON with Jackson library.
* @author dooman
*/
public class JSONUtils {
/**
* Creates new {@link ObjectMapper} with next features:<br/>
* -Disabled {@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES}<br/>
* -Enabled {@link DeserializationFeature#ACCEPT_SINGLE_VALUE_AS_ARRAY}<br/>
* -Disable {@link SerializationFeature#FAIL_ON_EMPTY_BEANS}
* @return
*/
public static ObjectMapper createMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
return mapper;
}
}