com.fasterxml.jackson.databind.SerializationFeature Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.SerializationFeature.
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: JacksonConfig.java From mall with MIT License | 6 votes |
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public Jackson2ObjectMapperBuilderCustomizer customJackson() { return new Jackson2ObjectMapperBuilderCustomizer() { @Override public void customize(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); builder.serializationInclusion(JsonInclude.Include.NON_NULL); builder.failOnUnknownProperties(false); builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } }; }
Example #2
Source File: TypeTest.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Test public void isSerializable() throws IOException { Type type = new Type("http://example.org/myType"); type.getOrCreatePredicate("http://example.org/myPredicate", Direction.OUT); type.getOrCreatePredicate("http://example.org/myPredicate", Direction.IN); ObjectMapper mapper = new ObjectMapper() .registerModule(new Jdk8Module()) .registerModule(new GuavaModule()) .registerModule(new TimbuctooCustomSerializers()) .enable(SerializationFeature.INDENT_OUTPUT); String result = mapper.writeValueAsString(type); Type loadedType = mapper.readValue(result, Type.class); assertThat(loadedType, is(type)); }
Example #3
Source File: ExampleJacksonReladomoBitemporalSerializerTest.java From reladomo with Apache License 2.0 | 6 votes |
@Test public void testInMemoryNoRelationships() throws Exception { String serialized = "{\n" + " \"_rdoClassName\" : \"com.gs.fw.common.mithra.test.domain.BitemporalOrderItem\",\n" + // " \"_rdoState\" : 20,\n" + " \"id\" : 70459,\n" + " \"orderId\" : 1,\n" + " \"productId\" : 1,\n" + " \"quantity\" : 20.0,\n" + " \"originalPrice\" : 10.5,\n" + " \"discountPrice\" : 10.5,\n" + " \"state\" : \"In-Progress\",\n" + " \"businessDate\" : 1567363437186\n" + "}\n"; ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JacksonReladomoModule()); mapper.enable(SerializationFeature.INDENT_OUTPUT); JavaType customClassCollection = mapper.getTypeFactory().constructCollectionLikeType(Serialized.class, BitemporalOrderItem.class); Serialized<BitemporalOrderItem> back = mapper.readValue(serialized, customClassCollection); BitemporalOrderItem wrapped = back.getWrapped(); Assert.assertEquals(70459, wrapped.getId()); Assert.assertEquals("In-Progress", wrapped.getState()); Assert.assertEquals(BitemporalOrderItemFinder.processingDate().getInfinityDate(), wrapped.getProcessingDate()); }
Example #4
Source File: CubeMetaExtractor.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void engineOverwriteInternal(File f) throws IOException { try { ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = objectMapper.readTree(f); boolean replaced = false; if (engineType != null && rootNode.get("engine_type") != null) { ((ObjectNode) rootNode).put("engine_type", Integer.parseInt(engineType)); replaced = true; } if (storageType != null && rootNode.get("storage_type") != null) { ((ObjectNode) rootNode).put("storage_type", Integer.parseInt(storageType)); replaced = true; } if (replaced) { objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.writeValue(f, rootNode); } } catch (JsonProcessingException ex) { logger.warn("cannot parse file {}", f); } }
Example #5
Source File: EsInstanceStore.java From soundwave with Apache License 2.0 | 6 votes |
public EsInstanceStore(String host, int port) { super(host, port); //This is required to let ES create the mapping of Date instead of long insertMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); updateMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .addMixIn(getInstanceClass(), IgnoreCreatedTimeMixin.class); //Specific mapper to read EsDailySnapshotInstance from the index essnapshotinstanceMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setPropertyNamingStrategy(new EsPropertyNamingStrategy( EsDailySnapshotInstance.class, EsInstanceStore.class)) .configure(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING, true); }
Example #6
Source File: DashboardConfigService.java From find with MIT License | 6 votes |
@Autowired public DashboardConfigService(final JsonDeserializer<TagName> tagNameDeserializer) { super( "dashboards.json", "defaultDashboardsConfigFile.json", DashboardConfig.class, DashboardConfig.builder().build(), new Jackson2ObjectMapperBuilder() .mixIn(Widget.class, WidgetMixins.class) .mixIn(WidgetDatasource.class, WidgetDatasourceMixins.class) .deserializersByType(ImmutableMap.of(TagName.class, tagNameDeserializer)) .serializersByType(ImmutableMap.of(TagName.class, new TagNameSerializer())) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) ); }
Example #7
Source File: SnapshotDataCommand.java From datacollector with Apache License 2.0 | 6 votes |
@Override public void run() { if(pipelineRev == null) { pipelineRev = "0"; } try { ManagerApi managerApi = new ManagerApi(getApiClient()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); System.out.println(mapper.writeValueAsString(managerApi.getSnapshot(pipelineId, snapshotName, pipelineRev))); } catch (Exception ex) { if(printStackTrace) { ex.printStackTrace(); } else { System.out.println(ex.getMessage()); } } }
Example #8
Source File: JdbcDataflowTaskExecutionMetadataDao.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
public JdbcDataflowTaskExecutionMetadataDao(DataSource dataSource, DataFieldMaxValueIncrementer incrementer) { this.incrementer = incrementer; this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); this.objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer(Resource.class, new ResourceDeserializer(new AppResourceCommon(new MavenProperties(), new DefaultResourceLoader()))); this.objectMapper.registerModule(module); this.objectMapper.addMixIn(Resource.class, ResourceMixin.class); this.objectMapper.addMixIn(AppDefinition.class, AppDefinitionMixin.class); this.objectMapper.addMixIn(AppDeploymentRequest.class, AppDeploymentRequestMixin.class); this.objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); this.dataSource = dataSource; }
Example #9
Source File: ObjectMapperProducer.java From hawkular-metrics with Apache License 2.0 | 6 votes |
@PostConstruct public void initMapper() { mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); SimpleModule module = new SimpleModule(); module.addDeserializer(AvailabilityType.class, new AvailabilityTypeDeserializer()); module.addDeserializer(MetricType.class, new MetricTypeDeserializer()); module.addSerializer(AvailabilityType.class, new AvailabilityTypeSerializer()); module.addKeySerializer(AvailabilityType.class, new AvailabilityTypeKeySerializer()); mapper.registerModule(module); }
Example #10
Source File: EsPropertyNamingStrategyTest.java From soundwave with Apache License 2.0 | 6 votes |
@Test public void deserializeWithStrategy() throws Exception { ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setPropertyNamingStrategy(new EsPropertyNamingStrategy( EsDailySnapshotInstance.class, EsInstanceStore.class)) .configure(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING, true); EsDailySnapshotInstance inst = mapper.readValue(doc, EsDailySnapshotInstance.class); Assert.assertEquals("coreapp-webapp-prod-0a018ef5", inst.getName()); Assert.assertEquals("fixed", inst.getLifecycle()); Assert.assertTrue(inst.getLaunchTime() != null); }
Example #11
Source File: ObjectMapperFactory.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public ObjectMapper createObjectMapper() { SimpleModule module = new SimpleModule(); module.addDeserializer(PropertyValue.class, new PropertyValueDeserializer()); module.addSerializer(SimplePropertyValue.class, new SimplePropertyValueSerializer()); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); objectMapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false); objectMapper.registerModule(module); objectMapper.registerModule(module); return objectMapper; }
Example #12
Source File: ObjectAsIdTest.java From typescript-generator with MIT License | 6 votes |
@Test public void testJacksonLists() throws JsonProcessingException { final TestObjectA testObjectA = new TestObjectA(); final TestObjectB testObjectB = new TestObjectB(); final TestObjectC<String> testObjectC = new TestObjectC<>("valueC"); final TestObjectD testObjectD = new TestObjectD(); final TestObjectE testObjectE = new TestObjectE(); final WrapperWithLists wrapper = new WrapperWithLists(); wrapper.listOfTestObjectA = Arrays.asList(testObjectA, testObjectA); wrapper.listOfTestObjectB = Arrays.asList(testObjectB, testObjectB); wrapper.listOfTestObjectC = Arrays.asList(testObjectC, testObjectC); wrapper.listOfTestObjectD = Arrays.asList(testObjectD, testObjectD); wrapper.listOfTestObjectE = Arrays.asList(testObjectE, testObjectE); final ObjectMapper objectMapper = Utils.getObjectMapper(); objectMapper.disable(SerializationFeature.INDENT_OUTPUT); final String json = objectMapper.writeValueAsString(wrapper); Assert.assertTrue(json.contains("\"listOfTestObjectA\":[\"id1\"")); Assert.assertTrue(json.contains("\"listOfTestObjectB\":[{")); Assert.assertTrue(json.contains("\"listOfTestObjectC\":[{")); Assert.assertTrue(json.contains("\"listOfTestObjectD\":[\"id4\"")); Assert.assertTrue(json.contains("\"listOfTestObjectE\":[\"id5\"")); }
Example #13
Source File: PollingState.java From autorest-clientruntime-for-java with MIT License | 6 votes |
/** * Initializes an object mapper. * * @param mapper the mapper to initialize * @return the initialized mapper */ private static ObjectMapper initMapper(ObjectMapper mapper) { mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true) .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .registerModule(new JodaModule()) .registerModule(ByteArraySerializer.getModule()) .registerModule(Base64UrlSerializer.getModule()) .registerModule(DateTimeSerializer.getModule()) .registerModule(DateTimeRfc1123Serializer.getModule()) .registerModule(HeadersSerializer.getModule()); mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.ANY) .withSetterVisibility(JsonAutoDetect.Visibility.NONE) .withGetterVisibility(JsonAutoDetect.Visibility.NONE) .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE)); return mapper; }
Example #14
Source File: ApiClient.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * Ctor. */ public ApiClient() { builder = HttpClient.newBuilder(); mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.registerModule(new JavaTimeModule()); JsonNullableModule jnm = new JsonNullableModule(); mapper.registerModule(jnm); URI baseURI = URI.create("http://petstore.swagger.io:80/v2"); scheme = baseURI.getScheme(); host = baseURI.getHost(); port = baseURI.getPort(); basePath = baseURI.getRawPath(); interceptor = null; readTimeout = null; responseInterceptor = null; }
Example #15
Source File: AbstractTest.java From terracotta-platform with Apache License 2.0 | 6 votes |
protected final void commonSetUp(Cluster cluster) throws Exception { this.cluster = cluster; mapper.configure(SerializationFeature.INDENT_OUTPUT, true); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.addMixIn(CapabilityContext.class, CapabilityContextMixin.class); mapper.addMixIn(Statistic.class, StatisticMixin.class); mapper.addMixIn(ContextualStatistics.class, ContextualStatisticsMixin.class); mapper.addMixIn(ConstantValueStatistic.class, ConstantValueStatisticMixin.class); connectManagementClient(cluster.getConnectionURI()); addWebappNode(cluster.getConnectionURI(), "pet-clinic"); addWebappNode(cluster.getConnectionURI(), "pet-clinic"); getCaches("pets"); getCaches("clients"); }
Example #16
Source File: GetCommittedOffsetsCommand.java From datacollector with Apache License 2.0 | 6 votes |
@Override public void run() { if(pipelineRev == null) { pipelineRev = "0"; } try { ManagerApi managerApi = new ManagerApi(getApiClient()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); System.out.println(mapper.writeValueAsString(managerApi.getCommittedOffsets(pipelineId, pipelineRev))); } catch (Exception ex) { if(printStackTrace) { ex.printStackTrace(); } else { System.out.println(ex.getMessage()); } } }
Example #17
Source File: JsonMapper.java From onetwo with Apache License 2.0 | 6 votes |
public JsonMapper(ObjectMapper objectMapper, Include include, boolean fieldVisibility){ objectMapper.setSerializationInclusion(include); // objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // setDateFormat(DateUtils.DATE_TIME); objectMapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); objectMapper.configure(Feature.ALLOW_COMMENTS, true); // objectMapper.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); if(fieldVisibility) objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); objectMapper.setFilterProvider(filterProvider); // objectMapper.addMixIn(target, mixinSource); this.objectMapper = objectMapper; this.typeFactory = this.objectMapper.getTypeFactory(); }
Example #18
Source File: ObjectMapperFactory.java From swagger-parser with Apache License 2.0 | 5 votes |
private static ObjectMapper create(JsonFactory jsonFactory, boolean includePathDeserializer, boolean includeResponseDeserializer) { ObjectMapper mapper = new ObjectMapper(jsonFactory); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }
Example #19
Source File: StatusDiff.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
public StatusDiff(Status current, Status desired) { // use SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS just for better human readability in the logs JsonNode source = patchMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true).valueToTree(current == null ? "{}" : current); JsonNode target = patchMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true).valueToTree(desired == null ? "{}" : desired); JsonNode diff = JsonDiff.asJson(source, target); int num = 0; for (JsonNode d : diff) { String pathValue = d.get("path").asText(); if (IGNORABLE_PATHS.matcher(pathValue).matches()) { log.debug("Ignoring Status diff {}", d); continue; } if (log.isDebugEnabled()) { log.debug("Status differs: {}", d); log.debug("Current Status path {} has value {}", pathValue, lookupPath(source, pathValue)); log.debug("Desired Status path {} has value {}", pathValue, lookupPath(target, pathValue)); } num++; } this.isEmpty = num == 0; }
Example #20
Source File: JobsConfiguration.java From zuihou-admin-cloud with Apache License 2.0 | 5 votes |
/** * json 类型参数 序列化问题 * Long -> string * date -> string * * @param builder * @return */ @Bean @Primary @ConditionalOnMissingBean public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { ObjectMapper objectMapper = builder.createXmlMapper(false) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .timeZone(TimeZone.getTimeZone("Asia/Shanghai")) .build(); //忽略未知字段 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //日期格式 SimpleDateFormat outputFormat = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT); objectMapper.setDateFormat(outputFormat); SimpleModule simpleModule = new SimpleModule(); /** * 将Long,BigInteger序列化的时候,转化为String */ simpleModule.addSerializer(Long.class, ToStringSerializer.instance); simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance); simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); objectMapper.registerModule(simpleModule); return objectMapper; }
Example #21
Source File: JsonDataFormatConfigurator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void configure(JacksonJsonDataFormat dataFormat) { ObjectMapper objectMapper = dataFormat.getObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.setDateFormat(DATE_FORMAT); }
Example #22
Source File: ObjectMapperProvider.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public ObjectMapperProvider() { this.mapper = new ObjectMapper() .enable(SerializationFeature.INDENT_OUTPUT) .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
Example #23
Source File: RpsConfig.java From rock-paper-scissors-in-java with MIT License | 5 votes |
public RpsConfig() throws Exception { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); GamesProjection gameProjection = new GamesProjection(); EventStoreEventStore eventStore = new EventStoreEventStore("game", mapper); ApplicationService applicationService = new ApplicationService(eventStore, Game.class); eventStore.all().collect(()-> gameProjection, ReflectionUtil::invokeHandleMethod); register(new RpsResource(applicationService, gameProjection)); register(new HandleAllExceptions()); }
Example #24
Source File: JacksonObjectToJsonConverter.java From spring-boot-data-geode with Apache License 2.0 | 5 votes |
/** * Constructs a new instance of the Jackson {@link ObjectMapper} class. * * @return a new instance of the Jackson {@link ObjectMapper} class. * @see com.fasterxml.jackson.databind.ObjectMapper */ protected @NonNull ObjectMapper newObjectMapper(@NonNull Object target) { Assert.notNull(target, "Target object must not be null"); return newObjectMapper() .addMixIn(target.getClass(), ObjectTypeMetadataMixin.class) .configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true) .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true) .configure(SerializationFeature.INDENT_OUTPUT, true) .findAndRegisterModules(); }
Example #25
Source File: JSON.java From datacollector with Apache License 2.0 | 5 votes |
public JSON() { mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); }
Example #26
Source File: JsonExport.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
public JsonExport() { mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.setDateFormat(new ISO8601DateFormat()); // Adding custom writer dynamically List<WorkflowBundleWriter> writers = io.getWriters(); writers.add(jsonWriter); io.setWriters(writers); }
Example #27
Source File: ExampleJacksonReladomoSerializerListTest.java From reladomo with Apache License 2.0 | 5 votes |
@Override protected String fromSerializedString(SerializedList serialized) throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JacksonReladomoModule()); mapper.enable(SerializationFeature.INDENT_OUTPUT); return mapper.writeValueAsString(serialized); }
Example #28
Source File: Zendesk.java From scava with Eclipse Public License 2.0 | 5 votes |
public static ObjectMapper createMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
Example #29
Source File: BaseObjectMapper.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public BaseObjectMapper(JsonFactory factory, WorkflowPropertySource workflowPropertySource) { super(factory); workflowModule = new WorkflowModule((workflowPropertySource)); configure(SerializationFeature.INDENT_OUTPUT, true); registerModule(workflowModule); }
Example #30
Source File: JacksonConfigurator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static ObjectMapper configureObjectMapper(ObjectMapper mapper) { SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString); mapper.setDateFormat(dateFormat); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); return mapper; }