Java JSON-RPC -- A minimalist fork of JSON.org, extending it for RPC, and '#' comments.
Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
src/com/augur/json
.gitignore
LICENSE.txt
README.md

README.md

JSON (+RPC)

This is a fork of the reference implementation by Douglas Crockford, provided at JSON.org, (which is based on ECMA-404, "The JSON Data Interchange Standard" and also documented as RFC 4627). When Mr. Crockford was asked by us to include RPC, he succinctly replied, "I don't believe in RPC." However, he welcomed any forks. This is this result.

There are three additions to the base code:

  1. Added three classes to support JSON-RPC v2.0: RPCError, RPCRequest, and RPCResponse
  2. Added support for comments in JSON syntax, when a line begins (No leading white space!) with a hash mark ('#')
  3. Added utility methods, JSONObject.keySet() and JSONObject.putAll()

Compatibility

This library should be backward compatible with any projects that used the JSON.org reference implementation.

Comment Syntax

My implementation of comments is limited to "a '#' at column zero" in order to minimally change the reference implementation's parsing code. Note that comments are ignored (not preserved) while parsing JSON, so if you later call JSONObject.toString(), there will be no comments. Note that comments are not part of the official JSON specification, so you'll just have to ignore any corresponding syntax errors flagged by your JSON file editor.

Build

The ANT build script offers two build sub-targets. The "build-core" target creates "json.jar" comprised of just the JSON and JSON-RPC classes. That's all you need for most JSON work.

The "build-plus" target creates "json+.jar" which includes the same core classes, plus extras that were included in the original JSON.org library, specifically: JSON translations for XML, CDL (comma-delimited list), and HTTP headers.

Just run 'ant' inside the 'build' directory to build both. The core json.jar is 40% smaller than the json+.jar file. (Obviously you only need one in your classpath.)

Copyright

The original work (most Java source files) are Copyright 2002 JSON.org.
Additional work is Copyright 2010-2016 Augur Systems, Inc.
See individual files for specifics.