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.tectonica.thirdparty.Jackson2.java
public static ObjectMapper createPropsMapper() { ObjectMapper mapper = new ObjectMapper(); // limit to props only mapper.setVisibility(PropertyAccessor.FIELD, Visibility.NONE); mapper.setVisibility(PropertyAccessor.GETTER, Visibility.ANY); mapper.setVisibility(PropertyAccessor.SETTER, Visibility.ANY); // general configuration mapper.setSerializationInclusion(Include.NON_NULL); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); return mapper; }
From source file:org.apache.ode.jacob.soup.jackson.JacobJacksonAnnotationIntrospector.java
@Override public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac, VisibilityChecker<?> checker) { return VisibilityChecker.Std.defaultInstance().with(Visibility.NONE).withVisibility(PropertyAccessor.FIELD, Visibility.ANY);/*from w w w.j a va 2 s.c o m*/ }
From source file:com.codenvy.cli.preferences.file.JsonPreferences.java
@JsonCreator protected JsonPreferences(Map<String, Object> innerPreferences) { this.callbackList = new ArrayList<>(); this.innerPreferences = new ConcurrentHashMap<String, Object>(innerPreferences); this.mapper = new ObjectMapper(); this.mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); this.mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); this.mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); this.mapper.setVisibility(PropertyAccessor.GETTER, Visibility.PUBLIC_ONLY); this.mapper.setVisibility(PropertyAccessor.IS_GETTER, Visibility.PUBLIC_ONLY); this.mapType = this.mapper.getTypeFactory().constructMapType(ConcurrentMap.class, String.class, Object.class); }
From source file:org.springframework.session.data.mongo.JacksonMongoSessionConverter.java
private ObjectMapper buildObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); // serialize fields instead of properties objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); // ignore unresolved fields (mostly 'principal') objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.setPropertyNamingStrategy(new MongoIdNamingStrategy()); return objectMapper; }
From source file:org.springframework.data.rest.webmvc.jpa.DataRest262Tests.java
@Before public void setUp() { mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); }
From source file:cc.arduino.packages.discoverers.PluggableDiscovery.java
@Override public void run() { // this method is started as a new thread, it will constantly listen // to the discovery tool and keep track of the discovered ports try {/* w ww . j a v a2 s. c o m*/ start(); InputStream input = program.getInputStream(); JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(input); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); while (program != null && program.isAlive()) { JsonNode tree = mapper.readTree(parser); if (tree == null) { if (program != null && program.isAlive()) { System.err.println(format("{0}: Invalid json message", discoveryName)); } break; } debug("Received json: " + tree); processJsonNode(mapper, tree); } debug("thread exit normally"); } catch (InterruptedException e) { debug("thread exit by interrupt"); e.printStackTrace(); } catch (Exception e) { debug("thread exit other exception"); e.printStackTrace(); } try { stop(); } catch (Exception e) { } }
From source file:com.gtcgroup.jped.test.core.rulechain.JptRuleChain.java
/** * @param testRule/* w w w .j a va 2s .c o m*/ * @return boolean */ protected static boolean isRuleAlreadyInvoked(final TestRule testRule) { boolean result = false; try { final ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); final String testRuleKey = mapper.writeValueAsString(testRule); if (testRule instanceof JptBaseForSuiteRule) { if (JptRuleChain.suiteRuleInstanceList.contains(testRuleKey)) { result = true; } JptRuleChain.suiteRuleInstanceList.add(testRuleKey); } else if (testRule instanceof JptBaseForClassRule) { if (JptRuleChain.classRuleInstanceList.contains(testRuleKey)) { result = true; } JptRuleChain.suiteRuleInstanceList.add(testRuleKey); } } catch (final Exception e) { throw new TestingException("TODO: message", e); } return result; }
From source file:org.apache.streams.jackson.StreamsJacksonMapper.java
public void configure() { disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE); configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, Boolean.TRUE); configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, Boolean.TRUE); configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, Boolean.TRUE); configure(DeserializationFeature.WRAP_EXCEPTIONS, Boolean.FALSE); configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, Boolean.TRUE); // If a user has an 'object' that does not have an explicit mapping, don't cause the serialization to fail. configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, Boolean.FALSE); configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, Boolean.FALSE); configure(SerializationFeature.WRITE_NULL_MAP_VALUES, Boolean.FALSE); setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.DEFAULT); }
From source file:net.java.html.charts.ChartsTest.java
/** * */ @BeforeMethod public void configureMapper() { mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); }
From source file:com.strategicgains.restexpress.serialization.json.DefaultJsonProcessor.java
/** * Template method for sub-classes to augment the mapper with desired * settings. Sub-classes should call super() to get default settings. * /*from w ww . j av a 2s .c o m*/ * @param module a SimpleModule */ protected void initializeMapper(ObjectMapper mapper) { mapper // .enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT) .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) // Ignore additional/unknown properties in a payload. .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) // Only serialize populated properties (do no serialize nulls) .setSerializationInclusion(JsonInclude.Include.NON_NULL) // Use fields directly. .setVisibility(PropertyAccessor.FIELD, Visibility.ANY) // Ignore accessor and mutator methods (use fields per above). .setVisibility(PropertyAccessor.GETTER, Visibility.NONE) .setVisibility(PropertyAccessor.SETTER, Visibility.NONE) .setVisibility(PropertyAccessor.IS_GETTER, Visibility.NONE) // Set default date output format. .setDateFormat(new SimpleDateFormat(DateAdapterConstants.TIME_POINT_OUTPUT_FORMAT)); }