List of usage examples for com.fasterxml.jackson.databind ObjectMapper configure
public ObjectMapper configure(JsonGenerator.Feature f, boolean state)
From source file:com.xeiam.xchange.mtgox.v2.service.trade.polling.FailureMessageJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = FailureMessageJSONTest.class .getResourceAsStream("/v2/trade/polling/example-failure-response-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxGenericResponse mtGoxGenericResponse = mapper.readValue(is, MtGoxGenericResponse.class); // System.out.println(mtGoxGenericResponse.getResult()); // Verify that the example data was unmarshalled correctly assertThat(mtGoxGenericResponse.getResult()).isEqualTo("error"); }
From source file:com.xeiam.xchange.mtgox.v2.service.trade.polling.SuccessMessageJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = SuccessMessageJSONTest.class .getResourceAsStream("/v2/trade/polling/example-success-response-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxGenericResponse mtGoxGenericResponse = mapper.readValue(is, MtGoxGenericResponse.class); // System.out.println(mtGoxGenericResponse.getResult()); // Verify that the example data was unmarshalled correctly assertThat(mtGoxGenericResponse.getResult()).isEqualTo("success"); }
From source file:codingpractice.renard314.com.products.network.JacksonRequest.java
@Override protected Response<T> parseNetworkResponse(NetworkResponse response) { try {/*from w ww .jav a2s . c o m*/ String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); T value = mapper.readValue(jsonString, responseType); return Response.success(value, HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (JsonMappingException e) { return Response.error(new ParseError(e)); } catch (JsonParseException e) { return Response.error(new ParseError(e)); } catch (IOException e) { return Response.error(new ParseError(e)); } }
From source file:com.xeiam.xchange.mtgox.v2.service.account.polling.WalletHistoryJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = WalletHistoryJSONTest.class .getResourceAsStream("/v2/account/example-wallethistory-response.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxWalletHistoryWrapper mtGoxWalletHistoryWrapper = mapper.readValue(is, MtGoxWalletHistoryWrapper.class); System.out.println(mtGoxWalletHistoryWrapper.toString()); // Verify that the example data was unmarshalled correctly assertThat(mtGoxWalletHistoryWrapper.getMtGoxWalletHistory() != null); assertThat(mtGoxWalletHistoryWrapper.getMtGoxWalletHistory().getRecords() == 46); }
From source file:fi.luontola.cqrshotel.Application.java
@Bean public ObjectMapper jacksonObjectMapper() { ObjectMapper om = new ObjectMapper(); om.registerModules(new JavaTimeModule(), new MoneyModule()); om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); om.configure(SerializationFeature.INDENT_OUTPUT, true); om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); om.configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, true); return om;//from www . j av a 2 s. c o m }
From source file:com.xeiam.xchange.mtgox.v0.service.trade.CancelOrdersJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = CancelOrdersJSONTest.class .getResourceAsStream("/v0/trade/example-cancel-order-response.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxCancelOrder mtGoxOpenOrders = mapper.readValue(is, MtGoxCancelOrder.class); // System.out.println(mtGoxOpenOrders.toString()); // Verify that the example data was unmarshalled correctly assertThat(mtGoxOpenOrders.getOrders().get(0).getAmount()).isEqualTo(new BigDecimal("0.92907324")); }
From source file:com.xeiam.xchange.mtgox.v2.service.marketdata.polling.DepthJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = DepthJSONTest.class.getResourceAsStream("/v2/marketdata/polling/example-depth-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxDepth mtGoxDepth = mapper.readValue(is, MtGoxDepth.class); // Verify that the example data was unmarshalled correctly assertThat(mtGoxDepth.getAsks().get(0).getAmountInt()).isEqualTo(246297453L); assertThat(mtGoxDepth.getFilterMaxPrice().getValueInt()).isEqualTo(20021100L); // SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // f.setTimeZone(TimeZone.getTimeZone("UTC")); // String dateString = f.format(DateUtils.fromMillisUtc(BTCETicker.getTicker().getServerTime() * 1000L)); // assertThat(dateString).isEqualTo("2012-12-22 19:12:09"); }
From source file:com.xeiam.xchange.mtgox.v2.service.marketdata.polling.TickerJSONTest.java
@Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources InputStream is = TickerJSONTest.class .getResourceAsStream("/v2/marketdata/polling/example-ticker-data.json"); // Use Jackson to parse it ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MtGoxTicker mtGoxTicker = mapper.readValue(is, MtGoxTicker.class); System.out.println(mtGoxTicker.toString()); // Verify that the example data was unmarshalled correctly assertThat(mtGoxTicker.getLast().getValue()).isEqualTo(new BigDecimal("91.46000")); assertThat(mtGoxTicker.getNow()).isEqualTo(1364669160478556L); }
From source file:cz.muni.fi.pa165.rest.layer.RootWebContext.java
@Bean @Primary/*from www. j a v a 2 s . c o m*/ public MappingJackson2HttpMessageConverter customJackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH)); objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION); jsonConverter.setObjectMapper(objectMapper); return jsonConverter; }
From source file:org.springframework.data.release.jira.JiraConfiguration.java
@Bean public ObjectMapper jacksonObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper; }