Java Json getJsonMapper()

Here you can find the source of getJsonMapper()

Description

get Json Mapper

License

Open Source License

Declaration

public static ObjectMapper getJsonMapper() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import com.fasterxml.jackson.annotation.JsonInclude;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.text.SimpleDateFormat;

public class Main {
    private static final ThreadLocal<ObjectMapper> mapper = new ThreadLocal<ObjectMapper>() {
        @Override/*from   w  ww . j  av a  2 s  .  c  o  m*/
        protected ObjectMapper initialValue() {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
            return objectMapper;
        }
    };

    public static ObjectMapper getJsonMapper() {
        return mapper.get();
    }
}

Related

  1. fill_list(JsonObjectBuilder jsonObject, String key, List list)
  2. fromDictionary(Map dictionary)
  3. getAsJSONArray(Object obj)
  4. getFromGson(String json, Class clazz)
  5. getJSONDate(long l)
  6. hasKey(JsonObject object, String name)
  7. jsonEquals(JsonArray expected, JsonArray actual, boolean strict)
  8. jsonObject(String key, JsonValue val)
  9. jsonObjectToBuilder(JsonObject jo)

  10. HOME | Copyright © www.java2s.com 2016