List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:org.jhk.pulsing.pulse.TrendingPulseSubTest.java
@BeforeClass public static void setup() { _objectMapper = new ObjectMapper(); _validResult = new LinkedHashMap<>(); _validResult.put(500L, "Mocked 500"); //5 count _validResult.put(200L, "Mocked 200"); //2 count _validResult.put(100L, "Mocked 100"); //1 count }
From source file:com.lorainelab.bitbucket.json.model.BitbucketPostTest.java
@Test public void urlEncoded() throws IOException { ObjectMapper objectMapper = new ObjectMapper(); String urlEncodedPost = Resources.toString( BitbucketPost.class.getClassLoader().getResource("samplePostUrlEncoded.txt"), Charsets.UTF_8); urlEncodedPost = java.net.URLDecoder.decode(urlEncodedPost.substring(8), "UTF-8"); BitbucketPost post = objectMapper.readValue(urlEncodedPost, BitbucketPost.class); Assert.assertNotNull(post);//from ww w . j a v a 2 s . c om Assert.assertEquals("master", post.getCommits().get(0).getBranch()); }
From source file:rest.RestWeather.java
public String getWeather() { restTemplate = new RestTemplate(); jacksonObjectMapper = new ObjectMapper(); map = restTemplate.getForObject(// w ww . j a v a 2 s . c om "http://api.apixu.com/v1/current.json?key=aebe5a3f024040ff9bf112640160705&q=Brussel", LinkedHashMap.class); weatherDescription = jacksonObjectMapper.convertValue(map.get("current"), Weather.class); //location = jacksonObjectMapper.convertValue(map.get(""), Location.class); return weatherDescription.getTemp_c() + " C"; }
From source file:com.shampan.db.collections.fragment.page.MemberInfo.java
public static MemberInfo getMemberInfo(String jsonContent) { MemberInfo memberInfo = null;//from w ww .j av a 2 s . co m try { ObjectMapper mapper = new ObjectMapper(); memberInfo = mapper.readValue(jsonContent, MemberInfo.class); } catch (Exception ex) { ex.printStackTrace(); } return memberInfo; }
From source file:retsys.client.json.JsonHelper.java
public JsonHelper(String message) { this.message = message; mapper = new ObjectMapper(); }
From source file:je.backit.rest.JacksonContextResolver.java
private static ObjectMapper init() { ObjectMapper om = new ObjectMapper(); om.registerModule(new JSR310Module()); om.registerModule(new JooqModule()); om.setSerializationInclusion(JsonInclude.Include.NON_NULL); om.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false) .configure(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false); om.configure(WRITE_DATES_AS_TIMESTAMPS, false); om.setVisibilityChecker(om.getSerializationConfig().getDefaultVisibilityChecker() .withIsGetterVisibility(NONE).withGetterVisibility(NONE).withFieldVisibility(ANY)); return om;//from w ww . ja va2 s.c o m }
From source file:org.hawkular.metrics.api.jaxrs.influx.write.validation.SupportedInfluxObjectTest.java
@Parameters(name = "supportedInfluxObject: {1}") public static Iterable<Object[]> testSupportedObjects() throws Exception { ObjectMapper mapper = new ObjectMapper(); URL resource = Resources.getResource("influx/write/supported-write-objects.list.json"); return FluentIterable // .from(Resources.readLines(resource, Charset.forName("UTF-8"))) // // Filter out comment lines .filter(new Predicate<String>() { @Override/*from w ww. jav a2s. c o m*/ public boolean apply(String input) { return !input.startsWith("//") && !input.trim().isEmpty(); } }) // .transform(new Function<String, Object[]>() { @Override public Object[] apply(String input) { try { return new Object[] { mapper.readValue(input, InfluxObject[].class), input }; } catch (IOException e) { throw new RuntimeException(e); } } }); }
From source file:com.hp.autonomy.hod.client.api.resource.ResourceTest.java
@Before public void setUp() { objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); }
From source file:dataLoader.Loader.java
public Loader(String jsonURL) { try {//w w w .j a va 2 s . c o m URL url = new URL(jsonURL); ObjectMapper mapper = new ObjectMapper(); record = mapper.readValue(url, mapper.getTypeFactory().constructCollectionType(List.class, support.JsonClass.class)); //System.out.println("size of record copied from url : "+record.size()); communityGroup = summary(record); } catch (java.io.IOException e) { System.out.println(e.toString()); } }
From source file:org.hawkular.metrics.api.jaxrs.influx.write.validation.UnsupportedInfluxObjectTest.java
@Parameters(name = "unsupportedInfluxObject: {1}") public static Iterable<Object[]> testSupportedObjects() throws Exception { ObjectMapper mapper = new ObjectMapper(); URL resource = Resources.getResource("influx/write/unsupported-write-objects.list.json"); return FluentIterable // .from(Resources.readLines(resource, Charset.forName("UTF-8"))) // // Filter out comment lines .filter(new Predicate<String>() { @Override//from www .java2 s. co m public boolean apply(String input) { return !input.startsWith("//") && !input.trim().isEmpty(); } }) // .transform(new Function<String, Object[]>() { @Override public Object[] apply(String input) { try { return new Object[] { mapper.readValue(input, InfluxObject[].class), input }; } catch (IOException e) { throw new RuntimeException(e); } } }); }