List of usage examples for com.fasterxml.jackson.databind ObjectReader readValue
@SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException
From source file:org.jenkinsci.plugins.jacksondatabind.JSONReadWrite.java
public static <T> T fromReader(Reader reader, Class<T> to) throws IOException { ObjectReader objReader = jsonMapper.reader(to); return objReader.readValue(reader); }
From source file:org.jenkinsci.plugins.uithemes.util.JSONReadWrite.java
public static <T> T fromString(String string, Class<T> to) throws IOException { ObjectReader reader = jsonMapper.reader(to); return reader.readValue(string); }
From source file:org.apache.metamodel.couchdb.CouchDbUtils.java
/** * Converts {@link JsonNode} to a {@link List}. * /*from w ww.j a v a 2 s .co m*/ * @param valueNode * The {@link JsonNode} to convert. * @return The {@link List} with values from {@link JsonNode}. */ public static Object jsonNodeToList(JsonNode valueNode) { if (valueNode == null) { return null; } try { ObjectReader reader = new ObjectMapper().reader(List.class); return reader.readValue(valueNode); } catch (Exception e) { throw new IllegalStateException(e); } }
From source file:org.apache.metamodel.couchdb.CouchDbUtils.java
/** * Converts {@link JsonNode} to a {@link Map}. * /*from ww w . jav a2 s . c o m*/ * @param valueNode * The {@link JsonNode} to convert. * @return The {@link Map} with values from {@link JsonNode}. */ public static Map<String, ?> jsonNodeToMap(JsonNode valueNode) { if (valueNode == null) { return null; } try { final ObjectReader reader = new ObjectMapper().reader(Map.class); return reader.readValue(valueNode); } catch (Exception e) { throw new IllegalStateException(e); } }
From source file:io.syndesis.rest.v1.state.ClientSideState.java
static Object deserialize(final Class<?> type, final byte[] pickle) { final ObjectReader reader = MAPPER.readerFor(type); try {/*w w w .j a v a 2 s. co m*/ return reader.readValue(pickle); } catch (final IOException e) { throw new IllegalArgumentException("Unable to deserialize given pickle to value", e); } }
From source file:de.bund.bfr.knime.node.editableTable.JSONDataTable.java
/** * Loads a table from the settings given. If any errors occur null is returned. * @param settings the settings to load from * @return the table/*from w w w . ja v a2s . c o m*/ * @since 2.10 */ @JsonIgnore public static JSONDataTable loadFromNodeSettings(final NodeSettingsRO settings) { String tableString = settings.getString(KNIME_DATA_TABLE_CONF, null); if (tableString == null) { return null; } ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JSONDataTable table = new JSONDataTable(); ObjectReader reader = mapper.readerForUpdating(table); ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(table.getClass().getClassLoader()); reader.readValue(tableString); return table; } catch (IOException e) { LOGGER.error("Unable to load JSON data table: " + e.getMessage(), e); return null; } finally { Thread.currentThread().setContextClassLoader(oldLoader); } }
From source file:com.cloudbees.workflow.util.JSONReadWrite.java
public <T> T fromString(String string, Class<T> to) throws IOException { ObjectReader reader = jsonMapper.reader(to); return reader.readValue(string); }
From source file:com.basistech.rosette.dm.json.plain.MorphoDeserializerTest.java
@Test public void comn130() throws Exception { ObjectMapper mapper = objectMapper(); ObjectReader reader = mapper.readerFor(AnnotatedText.class); // threw/* ww w . jav a 2 s .c om*/ reader.readValue(new File("test-data/comn-130-adm.json")); }
From source file:io.github.jdocker.common.vertx.JacksonCodec.java
@Override public Object decodeFromWire(int pos, Buffer buffer) { ObjectReader reader = mapper.reader(); try {// w w w. j av a 2s . c om return reader.readValue(buffer.toString(Charset.forName("UTF-8"))); } catch (IOException e) { throw new IllegalStateException("Cannot decode json", e); } }
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"); }