List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:de.devland.esperandro.serialization.JacksonSerializer.java
public JacksonSerializer() { objectMapper = new ObjectMapper(); }
From source file:com.boundary.sdk.util.UnixTimeSerializerTest.java
public static MyDate read(String resource) throws URISyntaxException { MyDate instance = new MyDate(); ClassLoader classLoader = instance.getClass().getClassLoader(); URL url = classLoader.getResource(resource); File file = new File(url.toURI()); ObjectMapper mapper = new ObjectMapper(); try {// www.ja v a2 s. c o m instance = mapper.readValue(file, MyDate.class); } catch (JsonParseException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return instance; }
From source file:es.logongas.iothome.agent.http.Http.java
public Http() { this.objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true); SimpleModule module = new SimpleModule(); module.addSerializer(java.util.Date.class, new DateSerializer()); objectMapper.registerModule(module); }
From source file:io.fabric8.forge.camel.commands.project.dto.NodeDtos.java
public static List<ContextDto> parseContexts(File file) throws java.io.IOException { ObjectMapper mapper = new ObjectMapper(); MappingIterator<ContextDto> iter = mapper.readerFor(ContextDto.class).readValues(file); return toList(iter); }
From source file:com.netsteadfast.greenstep.util.LocaleLanguageUtils.java
@SuppressWarnings("unchecked") public static Map<String, Object> loadDatas() { Map<String, Object> datas = null; try {//from w w w . j a v a2s. c o m datas = (Map<String, Object>) new ObjectMapper().readValue(_datas, LinkedHashMap.class); } catch (Exception e) { e.printStackTrace(); } return datas; }
From source file:net.floodlightcontroller.queuepusher.QueuePusherListResource.java
@Get("json") public String retrieve() { String sid = (String) getRequestAttributes().get("switch"); ObjectMapper mapper = new ObjectMapper(); QueuePusherResponse rsp = new QueuePusherResponse(QueuePusherResponseCode.NOT_IMPLEMENTED); Map<String, Object> jsonRsp = new HashMap<String, Object>(); jsonRsp.put("switch", sid); jsonRsp.put("qprsp", rsp.code); jsonRsp.put("out", rsp.out); jsonRsp.put("err", rsp.err); String jsonString = "-1"; try {//from w w w. j av a2s.com jsonString = mapper.writeValueAsString(jsonRsp); } catch (JsonProcessingException e) { logger.warn("Problem parsing JSON response", e); } return jsonString; }
From source file:org.javafunk.funk.jackson.monad.OptionDeserializerTest.java
@Before public void createObjectMapper() { objectMapper = new ObjectMapper().registerModule(new FunkModule()); }
From source file:com.trusolve.ant.filters.JsonToYamlFilter.java
public static Reader readDocument(Reader in) throws JsonProcessingException, IOException { ObjectMapper jsonIn = new ObjectMapper(); JsonNode jn = jsonIn.readTree(in);/*from w ww.ja v a 2s. co m*/ YAMLFactory yf = new YAMLFactory(); StringWriter sw = new StringWriter(); yf.createGenerator(sw).setCodec(new ObjectMapper(yf)).writeObject(jn); return new StringReader(sw.toString()); }
From source file:com.qubole.quark.planner.test.PartialCubeTest.java
protected static SqlQueryParser getParser(String filter) throws JsonProcessingException, QuarkException { Properties info = new Properties(); info.put("unitTestMode", "true"); info.put("schemaFactory", "com.qubole.quark.planner.test.PartialCubeSchemaFactory"); ImmutableList<String> defaultSchema = ImmutableList.of("TPCDS"); final ObjectMapper mapper = new ObjectMapper(); info.put("defaultSchema", mapper.writeValueAsString(defaultSchema)); info.put("filter", filter); return new SqlQueryParser(info); }
From source file:org.jboss.aerogear.sync.diffmatchpatch.JsonMapper.java
private static ObjectMapper createObjectMapper() { om = new ObjectMapper(); final SimpleModule module = new SimpleModule("DiffMatch", new Version(1, 0, 0, null, "aerogear", "sync")); module.addDeserializer(DiffMatchPatchEdit.class, new EditDeserializer()); module.addSerializer(DiffMatchPatchEdit.class, new EditSerializer()); module.addDeserializer(DiffMatchPatchMessage.class, new PatchMessageDeserializer()); module.addSerializer(DiffMatchPatchMessage.class, new PatchMessageSerializer()); om.registerModule(module);/*from w ww .j av a 2 s .c o m*/ return om; }