List of usage examples for com.fasterxml.jackson.databind ObjectMapper readValue
@SuppressWarnings("unchecked") public <T> T readValue(byte[] src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException
From source file:br.com.catbag.gifreduxsample.models.AppState.java
public static AppState fromJson(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new GuavaModule()); return mapper.readValue(json, AppState.class); }
From source file:com.shampan.db.collections.fragment.page.MemberInfo.java
public static MemberInfo getMemberInfo(String jsonContent) { MemberInfo memberInfo = null;//w w w .j av a2s. co m try { ObjectMapper mapper = new ObjectMapper(); memberInfo = mapper.readValue(jsonContent, MemberInfo.class); } catch (Exception ex) { ex.printStackTrace(); } return memberInfo; }
From source file:com.hellblazer.autoconfigure.configuration.YamlHelper.java
public static Configuration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(getModule());//ww w .j av a2 s.co m return mapper.readValue(yaml, Configuration.class); }
From source file:org.jboss.pnc.buildagent.api.TaskStatusUpdateEvent.java
public static TaskStatusUpdateEvent fromJson(String serialized) throws IOException { ObjectMapper mapper = new ObjectMapper(); try {// w w w. j a v a 2 s . com return mapper.readValue(serialized, TaskStatusUpdateEvent.class); } catch (JsonParseException | JsonMappingException e) { log.error("Cannot deserialize object from json", e); throw e; } }
From source file:com.hortonworks.registries.storage.util.StorageUtils.java
public static <T extends Storable> T jsonToStorable(String json, Class<T> clazz) throws IOException { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(json, clazz); }
From source file:com.chiralBehaviors.slp.hive.configuration.YamlHelper.java
public static EngineConfiguration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new EngineModule()); return mapper.readValue(yaml, EngineConfiguration.class); }
From source file:com.hellblazer.gossip.configuration.YamlHelper.java
public static GossipConfiguration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new GossipModule()); return mapper.readValue(yaml, GossipConfiguration.class); }
From source file:sonata.kernel.vimadaptor.wrapper.openstack.javastackclient.JavaStackUtils.java
public static String convertYamlToJson(String yamlToConvert) throws IOException { ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); Object obj = yamlReader.readValue(yamlToConvert, Object.class); ObjectMapper jsonWriter = new ObjectMapper(); return jsonWriter.writeValueAsString(obj); }
From source file:com.chiralBehaviors.autoconfigure.configuration.YamlHelper.java
public static Configuration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new GossipScopeModule()); return mapper.readValue(yaml, Configuration.class); }
From source file:io.acme.solution.domain.util.MementoBuilder.java
public static HashMap<String, Object> construct(final String state) { final ObjectMapper mapper = new ObjectMapper(); try {/* w ww . jav a 2 s . c o m*/ return (HashMap<String, Object>) mapper.readValue(state, HashMap.class); } catch (IOException exception) { log.debug("Failed to reconstruct memento object"); log.trace("Failed to reconstruct the memento attributes map", exception); return null; } }