JSON Streaming library

JSON Streaming library for Java

License

License

Categories

Categories

Net JSON Data
GroupId

GroupId

net.pwall.json
ArtifactId

ArtifactId

json-stream
Last Version

Last Version

0.8
Release Date

Release Date

Type

Type

jar
Description

Description

JSON Streaming library
JSON Streaming library for Java
Project URL

Project URL

https://github.com/pwall567/json-stream
Source Code Management

Source Code Management

https://github.com/pwall567/json-stream.git

Download json-stream

How to add to project

<!-- https://jarcasting.com/artifacts/net.pwall.json/json-stream/ -->
<dependency>
    <groupId>net.pwall.json</groupId>
    <artifactId>json-stream</artifactId>
    <version>0.8</version>
</dependency>
// https://jarcasting.com/artifacts/net.pwall.json/json-stream/
implementation 'net.pwall.json:json-stream:0.8'
// https://jarcasting.com/artifacts/net.pwall.json/json-stream/
implementation ("net.pwall.json:json-stream:0.8")
'net.pwall.json:json-stream:jar:0.8'
<dependency org="net.pwall.json" name="json-stream" rev="0.8">
  <artifact name="json-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.pwall.json', module='json-stream', version='0.8')
)
libraryDependencies += "net.pwall.json" % "json-stream" % "0.8"
[net.pwall.json/json-stream "0.8"]

Dependencies

compile (2)

Group / Artifact Type Version
net.pwall.json : jsonutil jar 5.0
net.pwall.util : pipelines jar 0.9

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.6.0

Project Modules

There are no modules declared in this project.

json-stream

JSON Streaming library for Java

This library allows JSON input to be parsed on the fly, avoiding the need to allocate memory for the largest possible input.

To use:

    JSONStream stream = new JSONStream();

As each character is received (for example, from an HTTP connection):

    stream.accept(ch)

When all characters have been processed:

    stream.close();

(If the characters are being read from a Reader, the EOF character may be passed to the stream; this will have the same effect as close().)

Alternatively, a String may be sent in a single operation (although this defeats the purpose of a byte-by-byte parser!); in this case the close() will be sent to the stream at the end of the data.

The resulting JSONValue (for example, a JSONObject) is available by calling:

    JSONValue = stream.getResult();

Pipeline

And now - JSONArrayPipeline. This class takes an Acceptor as a constructor argument (see pipelines), and as characters are fed to it from the string form of a JSON array, the parsed array elements are passed to the consumer. See the test for an example.

Dependency Specification

The latest version of the library is 0.8, and it may be obtained from the Maven Central repository.

Maven

    <dependency>
      <groupId>net.pwall.json</groupId>
      <artifactId>json-stream</artifactId>
      <version>0.8</version>
    </dependency>

Gradle

    implementation 'net.pwall.json:json-stream:0.8'

Gradle (kts)

    implementation("net.pwall.json:json-stream:0.8")

Peter Wall

2021-04-20

Versions

Version
0.8
0.7.1
0.7
0.6
0.5
0.4
0.3
0.2
0.1