Package ru.dreamteam.couch.util

Source Code of ru.dreamteam.couch.util.JSONUtils

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;
    }
}
TOP

Related Classes of ru.dreamteam.couch.util.JSONUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.