List of usage examples for com.fasterxml.jackson.databind ObjectMapper enable
public ObjectMapper enable(SerializationFeature f)
From source file:io.fouad.jtb.core.utils.JsonUtils.java
public static <T, R> T toJavaObject(String json, TypeReference typeReference) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); return mapper.readValue(json, typeReference); }
From source file:gov.bnl.channelfinder.MyJAXBContextResolver.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper result = new ObjectMapper(); result.enable(SerializationFeature.INDENT_OUTPUT); result.setAnnotationIntrospector(createJaxbJacksonAnnotationIntrospector()); return result; }
From source file:org.hawkular.rx.cdi.JacksonConfig.java
public static void initializeObjectMapper(ObjectMapper mapper) { mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES); mapper.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES); mapper.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); InventoryJacksonConfig.configure(mapper); //need to reconfigure for path serialization mapper.addMixIn(CanonicalPath.class, PathSerializationMixin.class); mapper.addMixIn(RelativePath.class, PathSerializationMixin.class); }
From source file:myStuff.rest.app.MyObjectMapper.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper result = new ObjectMapper(); result.enable(SerializationFeature.INDENT_OUTPUT); return result; }
From source file:com.mirth.connect.util.MirthJsonUtil.java
public static String prettyPrint(String input) { ObjectMapper mapper = new ObjectMapper(new JsonFactory()); mapper.enable(SerializationFeature.INDENT_OUTPUT); try {/*ww w . j a v a 2s.c o m*/ // Modified Jackson's default pretty printer to separate each array element onto its own line DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE); JsonNode json = mapper.readTree(input); return mapper.writer(prettyPrinter).writeValueAsString(json); } catch (Exception e) { logger.warn("Error pretty printing json.", e); } return input; }
From source file:org.bigloupe.web.monitor.util.JSONUtil.java
public static String formatJson(Object object) throws IOException { ObjectMapper om = new ObjectMapper(); om.enable(SerializationFeature.INDENT_OUTPUT); om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); return om.writeValueAsString(object); }
From source file:org.bigloupe.web.monitor.util.JSONUtil.java
/** * Writes object to the writer as JSON using Jackson and adds a new-line * before flushing.// ww w . j av a 2 s .c o m * * @param writer * the writer to write the JSON to * @param object * the object to write as JSON * @throws IOException * if the object can't be serialized as JSON or written to the * writer */ public static void writeJson(Writer writer, Object object) throws IOException { ObjectMapper om = new ObjectMapper(); om.enable(SerializationFeature.INDENT_OUTPUT); om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); writer.write(om.writeValueAsString(object)); writer.write("\n"); writer.flush(); }
From source file:com.github.segator.scaleway.api.Utils.java
public static ObjectMapper initializeObjectMapperJson() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); mapper.enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); mapper.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS); return mapper; }
From source file:org.nmdp.service.epitope.client.EpitopeServiceModule.java
@Provides @Singleton// ww w. j av a 2s.co m static EpitopeService createEpitopeService(@EndpointUrl final String endpointUrl) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT).setSerializationInclusion(Include.NON_NULL) .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); return new RestAdapter.Builder().setEndpoint(endpointUrl).setConverter(new JacksonConverter(objectMapper)) //.setRequestInterceptor(new GzipRequestInterceptor()) .build().create(EpitopeService.class); }
From source file:org.novamedia.novamail.jobserver.rest.ObjectMapperProvider.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.enable(SerializationFeature.INDENT_OUTPUT); return mapper; }