List of usage examples for com.fasterxml.jackson.databind ObjectMapper configure
public ObjectMapper configure(JsonGenerator.Feature f, boolean state)
From source file:com.example.damian.myjsonparsing.remote.service.CitiesService.java
protected ObjectMapper getObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); return objectMapper; }
From source file:net.nikore.gozer.marathon.MarathonModule.java
@Provides @Singleton/* w w w . j a va 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:io.github.mmichaelis.selenium.client.provider.PocTest.java
@Test public void serialize() throws Exception { final DesiredCapabilities capabilities = DesiredCapabilities.firefox(); final ObjectMapper mapper = new ObjectMapper(); mapper.configure(ALLOW_UNQUOTED_FIELD_NAMES, true); final String s = mapper.writeValueAsString(capabilities); LOG.info("json: {}", s); }
From source file:de.msg.message.jms.JmsConfiguration.java
@Bean public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.findAndRegisterModules(); return objectMapper; }
From source file:io.github.mmichaelis.selenium.client.provider.PocTest.java
@Test public void deserialize() throws Exception { // {"version":"","platform":"ANY","javascriptEnabled":true,"browserName":"firefox"} // {"browserName":"firefox"} final String toDeserialize = "{browserName:\"firefox\"}"; final ObjectMapper mapper = new ObjectMapper(); mapper.configure(ALLOW_UNQUOTED_FIELD_NAMES, true); final DesiredCapabilities obj = mapper.readValue(toDeserialize, DesiredCapabilities.class); LOG.info("obj: {}", obj); }
From source file:com.xeiam.xchange.mtgox.v2.service.account.polling.AccountInfoJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = AccountInfoJSONTest.class.getResourceAsStream("/v2/account/example-accountinfo-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxAccountInfo mtGoxAccountInfo = mapper.readValue(is, MtGoxAccountInfo.class); // Verify that the example data was unmarshalled correctly assertThat(mtGoxAccountInfo.getLogin()).isEqualTo("xchange"); }
From source file:com.xeiam.xchange.mtgox.v2.service.marketdata.polling.TradesJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = TradesJSONTest.class .getResourceAsStream("/v2/marketdata/polling/example-trades-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxTrade[] mtGoxTrades = mapper.readValue(is, MtGoxTrade[].class); // Verify that the example data was unmarshalled correctly assertThat(mtGoxTrades[0].getPriceInt()).isEqualTo(19399989L); }
From source file:com.xeiam.xchange.mtgox.v2.service.trade.polling.MtGoxLagJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = MtGoxLagJSONTest.class.getResourceAsStream("/v2/trade/polling/lag.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxLag MtGoxLag = mapper.readValue(is, MtGoxLag.class); // Verify that the example data was unmarshalled correctly assertThat(MtGoxLag.getLag()).isEqualTo(940304L); }
From source file:com.epam.ta.reportportal.ws.model.ErrorSerializationTest.java
private ObjectMapper getObjectMapper() { ObjectMapper om = new ObjectMapper(); om.configure(SerializationFeature.INDENT_OUTPUT, false); return om;/* w w w.ja v a 2s . c o m*/ }
From source file:io.gravitee.gateway.standalone.spring.StandaloneConfiguration.java
@Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new GraviteeMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }