List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:bear.plugins.java.JenkinsCacheTest.java
@Test public void testRead() throws Exception { ObjectReader reader = new ObjectMapper().reader(JenkinsCache.class); File file = new File("src/test/java/bear/plugins/java/jdks.json"); JenkinsCache cache = reader.readValue(file); assertThat(cache.findJDK("7u51").get().name).isEqualTo("jdk-7u51-linux-x64.tar.gz"); assertThat(cache.findJDK("7u51", false, true).get().name).isEqualTo("jdk-7u51-windows-x64.exe"); assertThat(cache.findJDK("6u45").get().name).isEqualTo("jdk-6u45-linux-x64.bin"); }
From source file:dk.dma.msiproxy.common.util.JsonUtils.java
/** * Formats the entity as json data//from ww w . j ava2 s .co m * * @param data the entity to format * @return the json data */ public static String toJson(Object data) throws IOException { ObjectMapper jsonMapper = new ObjectMapper(); return jsonMapper.writeValueAsString(data); }
From source file:org.omg.bpmn.miwg.configuration.BpmnCompareConfiguration.java
public static BpmnCompareConfiguration loadConfiguration(String confName) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); if (confName == null) { confName = "conf.json"; }/*from w ww. ja va 2s. com*/ InputStream is = BpmnCompareConfiguration.class.getResourceAsStream(confName); BpmnCompareConfiguration conf = mapper.readValue(is, BpmnCompareConfiguration.class); return conf; }
From source file:com.massivcode.weatherinfoexam.utils.NetworkUtil.java
public static WeatherInfo parseJsonToCurrentWeatherInfo(String jsonString) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); WeatherInfo weatherInfo = objectMapper.readValue(jsonString, WeatherInfo.class); return weatherInfo; }
From source file:org.sakuli.services.forwarder.icinga2.Icinga2ResultServiceImpl.java
public static String convertToJSON(Entity<?> entity) { try {//from w w w . ja v a 2 s . c om return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(entity.getEntity()); } catch (JsonProcessingException e) { return entity.getEntity().toString(); } }
From source file:ConcurrentTest.java
@BeforeClass public static void setUpClass() throws IOException { List<HashResultHolder> list = new ObjectMapper().readValue( JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"), new TypeReference<List<HashResultHolder>>() { });/*w ww. j a v a2 s . c om*/ IMAGE_FILE_RESULTS = list.stream() .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity())); }
From source file:org.robotninjas.barge.jaxrs.Jackson.java
/** * @return a new Object mapper with configured deserializer for barge' object model. *//*from w w w . j av a 2 s. co m*/ public static ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); SimpleModule raftMessagesModule = new SimpleModule("MyModule", new Version(0, 1, 0, null, "org.robotninjas", "barge")) .addDeserializer(RequestVote.class, new RequestVoteDeserializer()) .addDeserializer(HttpClusterConfig.class, new HttpClusterConfigDeserializer()) .addDeserializer(HttpReplica.class, new HttpReplicaDeserializer()) .addDeserializer(RequestVoteResponse.class, new RequestVoteResponseDeserializer()) .addDeserializer(AppendEntries.class, new AppendEntriesDeserializer()) .addDeserializer(AppendEntriesResponse.class, new AppendEntriesResponseDeserializer()); mapper.registerModule(raftMessagesModule); return mapper; }
From source file:org.fcrepo.transform.http.responses.JsonObjectProvider.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.setDateFormat(DATE_FORMAT);//w w w . j av a 2 s . com return mapper; }
From source file:com.shampan.db.codec.BasicProfileCodec.java
@Override public BasicProfileDAO decode(BsonReader reader, DecoderContext decoderContext) { Document document = documentCodec.decode(reader, decoderContext); ObjectMapper mapper = new ObjectMapper(); // mapper.configure(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); BasicProfileDAO basicProfile = new BasicProfileDAO(); try {/* ww w . j ava 2 s . c o m*/ basicProfile = mapper.readValue(document.toJson().toString(), BasicProfileDAO.class); } catch (Exception ex) { ex.printStackTrace(); } return basicProfile; }
From source file:net.landora.justintv.JustinTVAPI.java
public static List<JustinArchive> readArchives(String channelName, int offset, int maxNumber) throws Exception { String url = String.format("http://api.justin.tv/api/channel/archives/%s.json?offest=%d&limit=%d", channelName, offset, Math.min(100, maxNumber)); InputStream stream = openURL(url); ObjectMapper mapper = new ObjectMapper(); List<JustinArchive> readValue = mapper.readValue(stream, new TypeReference<List<JustinArchive>>() { });/* ww w. j a v a 2s .co m*/ return readValue; }