List of usage examples for com.fasterxml.jackson.annotation PropertyAccessor FIELD
PropertyAccessor FIELD
To view the source code for com.fasterxml.jackson.annotation PropertyAccessor FIELD.
Click Source Link
From source file:com.siemens.sw360.datahandler.couchdb.MapperFactory.java
/** * Creates an object mapper with the given personalization * * @return the personalized object mapper *///from w w w . ja v a2s . com @Override public ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); // General settings mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); // auto-detect all member fields mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE); // but only public getters mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE); // and none of "is-setters" // Do not include null mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // Classes mix-in for (Class type : classes) { mapper.addMixInAnnotations(type, DatabaseMixIn.class); } // Nested classes mix-in for (Class type : nestedClasses) { mapper.addMixInAnnotations(type, DatabaseNestedMixIn.class); } return mapper; }
From source file:com.tectonica.thirdparty.Jackson2.java
public static ObjectMapper createFieldsMapper() { ObjectMapper mapper = new ObjectMapper(); // limit to fields only mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE); mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE); // general configuration mapper.setSerializationInclusion(Include.NON_NULL); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); return mapper; }
From source file:de.ks.flatadocdb.defaults.DefaultEntityPersister.java
public DefaultEntityPersister() { mapper.findAndRegisterModules();// ww w . j a va2s.c o m mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.enableDefaultTyping(); mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); }
From source file:net.nikore.gozer.marathon.MarathonModule.java
@Provides @Singleton/* w ww.ja v a 2 s. co m*/ ObjectMapper provideObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); return mapper; }
From source file:com.josue.tiled2.client.network.WSNetworkClient.java
public WSNetworkClient(String host, int port, String map) { this.container = ContainerProvider.getWebSocketContainer(); String url = "ws://" + host + ":" + port + "/game/" + map; try {// www. ja v a 2 s. co m endpointURI = new URI(url); } catch (URISyntaxException ex) { System.err.println(":: NETWORK ERROR, MALFORMED URI SYNTAX: " + url + " ::"); } mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.setSerializationInclusion(Include.NON_NULL); }
From source file:org.talend.components.webtest.TestApplication.java
@Bean public Jackson2ObjectMapperBuilder jacksonBuilder() { return new Jackson2ObjectMapperBuilder() { @Override/* w ww.jav a 2 s .co m*/ public void configure(ObjectMapper objectMapper) { super.configure(objectMapper); objectMapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); objectMapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); } }; }
From source file:jp.classmethod.aws.brian.utils.BrianServerObjectMapperFactoryBean.java
@Override protected ObjectMapper createInstance() { ObjectMapper mapper = new ObjectMapper(); SimpleModule brianModule = new SimpleModule("brianServerModule", VERSION); brianModule.addSerializer(Trigger.class, new TriggerSerializer()); mapper.registerModule(brianModule);//from ww w.java 2 s . c o m mapper.registerModule(new Jdk8Module()); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZones.UNIVERSAL); mapper.setDateFormat(df); return mapper; }
From source file:it.bz.tis.integreen.carsharingbzit.api.ApiClient.java
public <T> T callWebService(ServiceRequest request, Class<T> clazz) throws IOException { request.request.technicalUser.username = this.user; request.request.technicalUser.password = this.password; ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.NONE) .setVisibility(PropertyAccessor.IS_GETTER, Visibility.PUBLIC_ONLY) .setVisibility(PropertyAccessor.GETTER, Visibility.PUBLIC_ONLY) .setVisibility(PropertyAccessor.SETTER, Visibility.PUBLIC_ONLY); mapper.enable(SerializationFeature.INDENT_OUTPUT); StringWriter sw = new StringWriter(); mapper.writeValue(sw, request);// w w w. j a v a 2s . co m String requestJson = sw.getBuffer().toString(); logger.debug("callWebService(): jsonRequest:" + requestJson); URL url = new URL(this.endpoint); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); OutputStream out = conn.getOutputStream(); out.write(requestJson.getBytes("UTF-8")); out.flush(); int responseCode = conn.getResponseCode(); InputStream input = conn.getInputStream(); ByteArrayOutputStream data = new ByteArrayOutputStream(); int len; byte[] buf = new byte[50000]; while ((len = input.read(buf)) > 0) { data.write(buf, 0, len); } conn.disconnect(); String jsonResponse = new String(data.toByteArray(), "UTF-8"); if (responseCode != 200) { throw new IOException(jsonResponse); } logger.debug("callWebService(): jsonResponse:" + jsonResponse); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); T response = mapper.readValue(new StringReader(jsonResponse), clazz); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); sw = new StringWriter(); mapper.writeValue(sw, response); logger.debug( "callWebService(): parsed response into " + response.getClass().getName() + ":" + sw.toString()); return response; }
From source file:org.pac4j.vertx.DefaultEventBusObjectConverter.java
public DefaultEventBusObjectConverter() { mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE); addMixIn(BearerAccessToken.class, BearerAccessTokenMixin.class); addMixIn(Scope.Value.class, ValueMixin.class); addMixIn(Token.class, TokenMixin.class); }
From source file:io.gumga.security.WebConfigForTest.java
private MappingJackson2HttpMessageConverter jacksonConverter() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Hibernate4Module()); mapper.registerModule(new JodaModule()); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.setDateFormat(new ISO8601DateFormat()); mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); jacksonConverter.setObjectMapper(mapper); return jacksonConverter; }