Example #1
1
 public Object parseAndClose(InputStream paramInputStream, Charset paramCharset, Type paramType)
     throws IOException {
   paramInputStream = jsonFactory.createJsonParser(paramInputStream, paramCharset);
   initializeParser(paramInputStream);
   return paramInputStream.parse(paramType, true);
 }
 /**
  * Method for reading sequence of Objects from parser stream.
  *
  * @since 1.8
  */
 public <T> MappingIterator<T> readValues(URL src) throws IOException, JsonProcessingException {
   JsonParser jp = _jsonFactory.createJsonParser(src);
   if (_schema != null) {
     jp.setSchema(_schema);
   }
   DeserializationContext ctxt = _createDeserializationContext(jp, _config);
   return new MappingIterator<T>(_valueType, jp, ctxt, _findRootDeserializer(_config, _valueType));
 }
Example #3
0
  private void process(File input) throws IOException {
    JsonFactory jsonF = new JsonFactory();
    JsonParser jp = jsonF.createJsonParser(input);
    TwitterEntry entry = read(jp);

    // let's write to a file, using UTF-8 encoding (only sensible one)
    StringWriter strw = new StringWriter();
    JsonGenerator jg = jsonF.createJsonGenerator(strw);
    jg.useDefaultPrettyPrinter(); // enable indentation just to make debug/testing easier

    // Here we would modify it... for now, will just (re)indent it

    write(jg, entry);

    System.out.println("Result = [" + strw.toString() + "]");
  }
 public JsonNode readTree(String content) throws IOException, JsonProcessingException {
   return _bindAndCloseAsTree(_jsonFactory.createJsonParser(content));
 }
 public JsonNode readTree(Reader r) throws IOException, JsonProcessingException {
   return _bindAndCloseAsTree(_jsonFactory.createJsonParser(r));
 }
 public JsonNode readTree(InputStream in) throws IOException, JsonProcessingException {
   return _bindAndCloseAsTree(_jsonFactory.createJsonParser(in));
 }
 @SuppressWarnings("unchecked")
 public <T> T readValue(URL src) throws IOException, JsonProcessingException {
   return (T) _bindAndClose(_jsonFactory.createJsonParser(src));
 }
 @SuppressWarnings("unchecked")
 public <T> T readValue(byte[] src, int offset, int length)
     throws IOException, JsonProcessingException {
   return (T) _bindAndClose(_jsonFactory.createJsonParser(src, offset, length));
 }