List of usage examples for com.fasterxml.jackson.databind ObjectMapper ObjectMapper
public ObjectMapper()
From source file:com.shampan.db.collections.fragment.common.Like.java
public static Like getLikeInfo(String jsonContent) { Like likeInfo = null;/*from w w w . j av a 2 s. co m*/ try { ObjectMapper mapper = new ObjectMapper(); likeInfo = mapper.readValue(jsonContent, Like.class); } catch (Exception ex) { ex.printStackTrace(); } return likeInfo; }
From source file:helper.SerializationHelper.java
public static String serializeObject(Object object) { ObjectMapper mapper = new ObjectMapper(); Writer strWriter = new StringWriter(); try {/*from w w w. j a va 2 s .co m*/ mapper.configure(SerializationFeature.INDENT_OUTPUT, true); mapper.writeValue(strWriter, object); } catch (Exception e) { System.out.println(e); } return strWriter.toString(); }
From source file:com.mgatelabs.bytemapper.support.definitions.FormatDefinition.java
public static FormatDefinition load(InputStream is) throws Exception { ObjectMapper mapper = new ObjectMapper(); FormatDefinition def;/* w w w .j av a 2 s . c o m*/ try { def = mapper.readValue(is, FormatDefinition.class); } finally { is.close(); } def.sanity(); return def; }
From source file:com.playonlinux.core.python.JsonCodec.java
public static String dumps(Map<String, Object> map) throws IOException { return new ObjectMapper().writeValueAsString(map); }
From source file:org.apache.solr.kelvin.testcases.SimpleConditionTest.java
public static JsonNode readJsonResource(Class<?> c, String resourceName) throws IOException { String raw = IOUtils.toString(c.getResourceAsStream(resourceName), "utf8"); ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(raw, JsonNode.class); }
From source file:com.yahoo.gondola.container.RegistryClients.java
/** * create zookeeper client via config.// www .j av a2s .com * @param config The Gondola config * @return The ZookeeperRegistryClient instance */ public static RegistryClient createZookeeperClient(Config config) throws IOException { CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(getZookeeperConnectionString(config)).retryPolicy(new RetryOneTime(1000)).build(); client.start(); return new ZookeeperRegistryClient(client, new ObjectMapper(), config); }
From source file:de.stadtrallye.rallyesoft.util.converters.Serialization.java
public static ObjectMapper getJsonInstance() { if (jsonMapper == null) { jsonMapper = new ObjectMapper(); }//from ww w. j a va 2 s . co m return jsonMapper; }
From source file:org.lable.rfc3881.auditlogger.serialization.ObjectMapperFactory.java
/** * Configures an {@link ObjectMapper} instance with the serialization strategies needed for this project. * * @return An object-mapper./*from w ww . ja va 2s . c o m*/ */ public static ObjectMapper getObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new RFC3881Module()); objectMapper.registerModule(new JodaModule()); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); return objectMapper; }
From source file:com.shampan.db.collections.fragment.common.Share.java
public static Share getStatusShare(String jsonContent) { Share shareInfo = null;//from w w w. j a v a 2 s .c om try { ObjectMapper mapper = new ObjectMapper(); shareInfo = mapper.readValue(jsonContent, Share.class); } catch (Exception ex) { ex.printStackTrace(); } return shareInfo; }
From source file:de.elanev.studip.android.app.backend.datamodel.Settings.java
public static Settings fromJson(String jsonString) { ObjectMapper mapper = new ObjectMapper(); Settings settings = null;/*ww w . j av a2 s .com*/ try { settings = mapper.readValue(jsonString, Settings.class); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return settings; }