com.fasterxml.jackson.core.json.JsonReadFeature Java Examples
The following examples show how to use
com.fasterxml.jackson.core.json.JsonReadFeature.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonUtil.java From blade-tool with GNU Lesser General Public License v3.0 | 7 votes |
public JacksonObjectMapper() { super(); //设置地点为中国 super.setLocale(CHINA); //去掉默认的时间戳格式 super.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); //设置为中国上海时区 super.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault())); //序列化时,日期的统一格式 super.setDateFormat(new SimpleDateFormat(DateUtil.PATTERN_DATETIME, Locale.CHINA)); //序列化处理 super.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true); super.configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true); super.findAndRegisterModules(); //失败处理 super.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); super.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //单引号处理 super.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); //反序列化时,属性不存在的兼容处理s super.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); //日期格式化 super.registerModule(new BladeJavaTimeModule()); super.findAndRegisterModules(); }
Example #2
Source File: JsonUtil.java From mica with GNU Lesser General Public License v3.0 | 5 votes |
private static JsonFactory jsonFactory() { return JsonFactory.builder() // 可解析反斜杠引用的所有字符 .configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER, true) // 允许JSON字符串包含非引号控制字符(值小于32的ASCII字符,包含制表符和换行符) .configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS, true) .build(); }
Example #3
Source File: AbstractRequestTest.java From act-platform with ISC License | 5 votes |
@BeforeClass public static void setUp() { // Initialize object mapper for testing. With this configuration we save a lot of quotes and escaping when creating JSON strings. mapper = JsonMapper.builder() .enable(JsonReadFeature.ALLOW_UNQUOTED_FIELD_NAMES) .enable(JsonReadFeature.ALLOW_SINGLE_QUOTES) .build(); // Initialize validator for testing including custom mappings. validator = Validation.byDefaultProvider() .configure() .addMapping(AbstractRequestTest.class.getClassLoader().getResourceAsStream(VALIDATION_MAPPINGS)) .buildValidatorFactory() .getValidator(); }