@Override public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return readerFor(type).with(schema).readValue(src); }
.with(csvSchema) .withFeatures(features.toArray(new CsvParser.Feature[features.size()]));
/** * Configures json with the given properties * * @param reader */ private ObjectReader configureObjectMapperForJSON(ObjectReader reader) { reader = reader.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); reader = reader.with(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); return reader; }
public DataFormatReaders with(DeserializationConfig config) { final int len = _readers.length; ObjectReader[] r = new ObjectReader[len]; for (int i = 0; i < len; ++i) { r[i] = _readers[i].with(config); } return new DataFormatReaders(r, _optimalMatch, _minimalMatch, _maxInputLookahead); }
@Override public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return readerFor(type).with(schema).readValue(src); }
/** * Factory method for constructing {@link ObjectReader} that will * use specified {@link JsonNodeFactory} for constructing JSON trees. */ public ObjectReader reader(JsonNodeFactory f) { return _newReader(getDeserializationConfig()).with(f); }
/** * Factory method for constructing {@link ObjectReader} with * default settings. Note that the resulting instance is NOT usable as is, * without defining expected value type. */ public ObjectReader reader() { return _newReader(getDeserializationConfig()).with(_injectableValues); }
result = reader.with(DeserializationFeature.READ_ENUMS_USING_TO_STRING).readValue(node);
@Override public TrueFxTicker deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { ArrayNode array = mapper.readerFor(TrueFxTicker.class).with(schema).readTree(parser); String pair = array.get(0).asText(); long timestamp = array.get(1).asLong(); BigDecimal bid = new BigDecimal(array.get(2).asText()); BigDecimal bidBP = new BigDecimal(array.get(3).asText()); BigDecimal ask = new BigDecimal(array.get(4).asText()); BigDecimal askBP = new BigDecimal(array.get(5).asText()); BigDecimal low = new BigDecimal(array.get(6).asText()); BigDecimal high = new BigDecimal(array.get(7).asText()); BigDecimal open = new BigDecimal(array.get(8).asText()); return new TrueFxTicker(pair, timestamp, bid, bidBP, ask, askBP, low, high, open); } }
@Parameters @Test public void testSerDesr(DimensionSpec lookupDimSpec) throws IOException { ObjectMapper mapper = new DefaultObjectMapper(); mapper.registerSubtypes(new NamedType(LookupDimensionSpec.class, "lookup")); InjectableValues injectableValues = new InjectableValues.Std().addValue( LookupReferencesManager.class, LOOKUP_REF_MANAGER ); String serLookup = mapper.writeValueAsString(lookupDimSpec); Assert.assertEquals(lookupDimSpec, mapper.readerFor(DimensionSpec.class).with(injectableValues).readValue(serLookup)); }
private Object[] convertJsonToParameters(Method m, List<JsonNode> params) throws IOException { Object[] convertedParams = new Object[params.size()]; Type[] parameterTypes = m.getGenericParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { JsonParser paramJsonParser = mapper.treeAsTokens(params.get(i)); JavaType paramJavaType = mapper.getTypeFactory().constructType(parameterTypes[i]); convertedParams[i] = mapper.readerFor(paramJavaType) .with(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) .readValue(paramJsonParser); } return convertedParams; }
.with(ContextAttributes.getEmpty() .withSharedAttribute("project", project) .withSharedAttribute("useHeader", useHeader) .withSharedAttribute("collection", query.collection) .withSharedAttribute("apiKey", masterKey)) .with(builder.build()).readValue(url); } else if (query.type == AVRO) { URLConnection conn = url.openConnection();
.with(ContextAttributes.getEmpty() .withSharedAttribute("project", key.project)) .readValue(stringify.toString());
public JsonDumpFileProcessor( EntityDocumentProcessor entityDocumentProcessor, String siteIri) { this.entityDocumentProcessor = entityDocumentProcessor; this.mapper = new DatamodelMapper(siteIri); this.documentReader = this.mapper .readerFor(EntityDocumentImpl.class) .with(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT); }
"1/2/09 4:53,Product2,1500\n"; EventList actual = mapper.reader(EventList.class).with(ContextAttributes.getEmpty() .withSharedAttribute("project", "project") .withSharedAttribute("collection", "collection")
/** * Factory method for constructing {@link ObjectReader} with * default settings. Note that the resulting instance is NOT usable as is, * without defining expected value type. */ public ObjectReader reader() { return new ObjectReader(this, getDeserializationConfig()) .with(_injectableValues); }
/** * Factory method for constructing {@link ObjectReader} that will * use specified {@link JsonNodeFactory} for constructing JSON trees. */ public ObjectReader reader(JsonNodeFactory f) { return new ObjectReader(this, getDeserializationConfig()).with(f); }
/** * Factory method for constructing {@link ObjectReader} that will * use specified {@link JsonNodeFactory} for constructing JSON trees. */ public ObjectReader reader(JsonNodeFactory f) { return _newReader(getDeserializationConfig()).with(f); }
MappingIterator<Map> it = mapper.readerFor(Map.class).with(schema.build()).readValues(csvFile); while (it.hasNext()) { Map<String, Object> row = it.next();