/** * Returns a function (reader) converting {@link Flow.Publisher Publisher} of {@link java.nio.ByteBuffer}s to * a JSON-P object. * <p> * It is intended for derivation of others, more specific readers. * * @param charset a charset to use charset * @return the byte array content reader that transforms a publisher of byte buffers to a completion stage that * might end exceptionally with a {@link IllegalArgumentException} in case of I/O error or * a {@link javax.json.JsonException} */ public Reader<JsonStructure> reader(Charset charset) { return (publisher, clazz) -> ContentReaders.byteArrayReader() .apply(publisher) .thenApply(bytes -> jsonReaderFactory.createReader(new ByteArrayInputStream(bytes), charset).read()); }
@Override public <T> T readObject(Type targetType) { try { return readObject(jsonReader.readValue(), targetType); } catch (final NoSuchMethodError noSuchMethodError) { // jsonp 1.0 fallback - mainly for tests return readObject(jsonReader.read(), targetType); } }
@Override public JsonStructure readFrom(Class<JsonStructure> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JsonReader reader = findReader(mediaType, entityStream); try { return reader.read(); } finally { reader.close(); } }
/** * Creates a new ChaincodeCollectionConfiguration instance configured with details supplied in JSON format * * @param configStream A stream opened on a JSON document containing network configuration details * @return A new ChaincodeCollectionConfiguration instance * @throws InvalidArgumentException */ public static ChaincodeCollectionConfiguration fromJsonStream(InputStream configStream) throws InvalidArgumentException, ChaincodeCollectionConfigurationException { logger.trace("ChaincodeCollectionConfiguration.fromJsonStream..."); // Sanity check if (configStream == null) { throw new InvalidArgumentException("configStream must be specified"); } // Read the input stream and convert to JSON try (JsonReader reader = Json.createReader(configStream)) { return fromJsonObject((JsonArray) reader.read()); } }
/** * Creates a new NetworkConfig instance configured with details supplied in JSON format * * @param configStream A stream opened on a JSON document containing network configuration details * @return A new NetworkConfig instance * @throws InvalidArgumentException */ public static NetworkConfig fromJsonStream(InputStream configStream) throws InvalidArgumentException, NetworkConfigurationException { logger.trace("NetworkConfig.fromJsonStream..."); // Sanity check if (configStream == null) { throw new InvalidArgumentException("configStream must be specified"); } // Read the input stream and convert to JSON try (JsonReader reader = Json.createReader(configStream)) { JsonObject jsonConfig = (JsonObject) reader.read(); return fromJsonObject(jsonConfig); } }
JsonObject jobj = (JsonObject) reader.read();
JsonObject jsonst = (JsonObject) reader.read();
JsonObject jsonst = (JsonObject) reader.read();
@Override protected JsonStructure doRead(final JsonReader jsonReader) { return jsonReader.read(); } }
@Override protected JsonStructure doRead(final JsonReader jsonReader) { return jsonReader.read(); } }
@Override public JsonStructure parseToObject(InputStream in) { try (JsonReader reader = Json.createReader(in)) { return reader.read(); } }
public JsonValue read(final JsonReader reader) { if (johnzon) { return JohnzonReaderHandler.read(reader); } return reader.read(); }
@Override public JsonStructure readFrom(Class<JsonStructure> jsonStructureClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream inputStream) throws IOException, WebApplicationException { try (JsonReader reader = rf.createReader(inputStream)) { return reader.read(); } } }
public JsonValue read(final JsonReader reader) { if (johnzon) { return JohnzonReaderHandler.read(reader); } return reader.read(); }
@Override public JsonStructure read() { try { return this.origin.read(); } catch (final JsonParsingException ex) { throw new JsonParsingException( this.json, ex, ex.getLocation() ); } } @Override
private Object readResolve() throws ObjectStreamException { final JsonReader parser = factory().createReader(new StringReader(value)); try { return parser.read(); } finally { parser.close(); } }
@SuppressWarnings("unchecked") @Override public T readFrom(Class<T> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream in) throws IOException, WebApplicationException { try (JsonReader jr = Json.createReader(in)) { JsonStructure read = jr.read(); return (T) converter.convert(read).to(arg1); } } }
@SuppressWarnings("unchecked") @Override public T readFrom(Class<T> arg0, Type arg1, Annotation[] arg2, MediaType arg3, MultivaluedMap<String, String> arg4, InputStream in) throws IOException, WebApplicationException { try (JsonReader jr = Json.createReader(in)) { JsonStructure read = jr.read(); return (T) converter.convert(read).to(arg1); } } }
public ArrayList<LinkedHashMap<String, List<String>>> getData() { JsonReader reader = Json.createReader(is); JsonValue value = reader.read(); convertTreeToHashMap(value, EMPTY_KEY); getFlatJsonTree().add(individualSectionOfTree); setFlatJsonTree(flatJsonTree); return getFlatJsonTree(); }
private static DocumentRoot<QName> read(Reader stream) throws Exception { JsonReader reader = Json.createReaderFactory(Collections.<String, Object> emptyMap()).createReader(stream); JsonIo jsonIo = new JsonIo(); IoReader<String> ioReader = jsonIo.createIoReader(reader.read()); DocumentRoot<String> root = ioReader.read(); return StringifyQName.string2qname.mapDR(root); } }