See: Description
Interface | Description |
---|---|
JSONReader | |
JSONStreams |
Service for generating readable and writable JSON streams from character
streams.
|
JSONToken |
A token in a JSON character stream.
|
JSONWriter |
Writes JSON content to a character stream.
|
Enum | Description |
---|---|
JSONToken.Type |
Enumerates the different kinds of tokens that occur in a JSON stream
|
Exception | Description |
---|---|
JSONIOException |
An unchecked exception raised whenever a checked
IOException is
encountered on the underlying stream that the JSON API is operating on. |
JSONStreams.jsonReader(Readable)
method.
@Provides class SomePlugin implements SomeService { @Inject SomePlugin(JSONStreams json) { this.json = json; } @Override public void someMethod(java.io.Reader stream) { final JSONReader reader = json.jsonReader(stream); while ( reader.hasNext() ) { JSONToken token = reader.next(); switch(token.type()) { //process JSON tokens here ... } } private final JSONStreams json; }
CharSequence
including the String
class using the JSONStreams.jsonReader(CharSequence)
method.
final JSONStreams json = ... ; String text = ...; // contents of text is a JSON document final JSONReader reader = json.jsonReader(text); while ( reader.hasNext() ) { JSONToken token = reader.next(); switch(token.type()) { //process JSON tokens here ... } }
Appendable
instance, including StringBuilder
and all sub-classes of Writer
,using the JSONStreams.jsonWriter(Appendable)
method.
final JSONStreams json = ... ; StringBuilder text = new StringBuilder(); final JSONWriter writer = json.jsonWriter(text); writer.startObject().property("foo","bar").endObject(); System.out.println(text); // emits: {"foo":"bar"}
JSONToken
instances using JSONReader
and then appended to a JSONWriter
instance
JSONStreams json = ...; String embedded = "{\"a\":\"b\"}"; JSONReader reader = json.jsonReader(embedded); StringBuilder output = new StringBuilder(); JSONWriter writer = json.jsonWriter(output); writer.startObject(); writer.propertyName("c"); // append the nested content while (reader.hasNext()) { writer.append(reader.next()); } writer.endObject(); System.out.println(output); // emits: {"c":{"a":"b"}}
Oracle REST Data Services Plugin API version: 3.0.0.65.09.35 Copyright © 2015 Oracle Corp. All Rights Reserved.