Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Commit

Permalink
extended examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Krause committed Mar 18, 2016
1 parent b007522 commit c8b360c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,27 @@ The [`JsonPushParser`][JsonPushParser] takes a [`JsonHandler`][JsonHandler], aut

Both parsers consume a [`JsonSource`][JsonSource], which represents a character stream and the necessary methods to it.

This library provides the [`ReaderJsonStream`][ReaderJsonStream], which buffers and consumes the characters that are yielded by a given [`Reader`][Reader]. Additionally, this library provides the [`StringJsonSource`][StringJsonSource] and the [`CharacterArrayJsonSource`][CharacterArrayJsonSource] that can be used to parse the characters from an existing string or an existing `char[]`.
This library provides the [`ReaderJsonStream`][ReaderJsonStream], which buffers and consumes the characters that are yielded by a given [`Reader`][Reader].

It is usually not necessary to create a [`JsonSource`][JsonSource] directly, because both parsers have convenient constructors, that create an appropriate [`JsonSource`][JsonSource].
```java
Reader reader = ...

// create a new json source for reader
JsonSource jsonSource = new ReaderJsonSource(reader);
```

Additionally, this library provides the [`StringJsonSource`][StringJsonSource] and the [`CharacterArrayJsonSource`][CharacterArrayJsonSource] that can be used to parse the characters from an existing string or an existing `char[]`.

```java
String string = ...
char[] chars = ...

// create new json sources for string and chars
JsonSource stringJsonSource = new StringJsonSource(string);
JsonSource characterArrayJsonSource = new CharacterArrayJsonSource(chars);
```

*It is usually not necessary to create a [`JsonSource`][JsonSource] directly, because both parsers have convenient constructors, that create an appropriate [`JsonSource`][JsonSource].*

## Push parser

Expand Down Expand Up @@ -109,4 +127,4 @@ JSONArray jsonArray = JsonUtil.readObject(new FileReader(file));
[JSONArray]: https://stleary.github.io/JSON-java/index.html?org/json/JSONArray.html
[JSONObject]: https://stleary.github.io/JSON-java/index.html?org/json/JSONObject.html

[Reader]: http://docs.oracle.com/javase/8/docs/api/index.html?java/io/Reader.html
[Reader]: http://docs.oracle.com/javase/8/docs/api/index.html?java/io/Reader.html;

0 comments on commit c8b360c

Please sign in to comment.