OSDN Git Service

A cleanroom implementation of the org.json API.
authorJesse Wilson <jessewilson@google.com>
Fri, 12 Mar 2010 08:52:29 +0000 (00:52 -0800)
committerJesse Wilson <jessewilson@google.com>
Sat, 13 Mar 2010 01:36:17 +0000 (17:36 -0800)
commit4558195b4a7ee014517f1aa3c59bc6c561baa2ef
treebc070af09f5b47aed3b28f39fd9d06325531f9da
parent6f9b4d2bdccb2ea5e548b908e5cc882d262d0940
A cleanroom implementation of the org.json API.

This implementation lacks documentation. I intend to write that after checking
it into the master branch. By not waiting we'll have more time to exercise the
code, if only in Google's own applications.

This passes all of my tests. I rewrote some of the tests to make Crockford's
implementation fail. The tests that fail on Crockford's implementation are:

  JSONArrayTest
  testEqualsAndHashCode equals() not consistent with hashCode()
  testTokenerConstructorParseFail StackOverflowError
  testStringConstructorParseFail StackOverflowError

  JSONObjectTest
  testOtherNumbers Object.put() accepted a NaN (via a custom Number class)
  testMapConstructorWithBogusEntries JSONObject constructor doesn't validate its input!

  JSONTokenerTest
  testNextNWithAllRemaining off-by-one error?
  testNext0 Returning an empty string should be valid
  testNextCleanCommentsTrailingSingleSlash nextClean doesn't consume a trailing slash
  assertNotClean The character line tabulation is not whitespace according to the JSON spec.
  testNextToDoesntStopOnNull nextTo() shouldn't stop after \0 characters
  testNextToConsumesNull nextTo shouldn't consume \0.
  testSkipToStopsOnNull skipTo shouldn't stop when it sees '\0'

  ParsingTest
  testParsingLargeHexValues For input "0x80000000" Hex values are parsed as Strings if their signed value is greater than Integer.MAX_VALUE.
  testSyntaxProblemUnterminatedArray Stack overflowed on input "["

Change-Id: I44c4a4a698a66bf043ed339d6bd804951e732cbf
13 files changed:
libcore/json/src/rewrite/java/org/json/JSON.java [new file with mode: 0644]
libcore/json/src/rewrite/java/org/json/JSONArray.java [new file with mode: 0644]
libcore/json/src/rewrite/java/org/json/JSONException.java [new file with mode: 0644]
libcore/json/src/rewrite/java/org/json/JSONObject.java [new file with mode: 0644]
libcore/json/src/rewrite/java/org/json/JSONStringer.java [new file with mode: 0644]
libcore/json/src/rewrite/java/org/json/JSONTokener.java [new file with mode: 0644]
libcore/json/src/test/java/org/json/AllTests.java
libcore/json/src/test/java/org/json/JSONArrayTest.java
libcore/json/src/test/java/org/json/JSONObjectTest.java
libcore/json/src/test/java/org/json/JSONStringerTest.java
libcore/json/src/test/java/org/json/JSONTokenerTest.java
libcore/json/src/test/java/org/json/ParsingTest.java [new file with mode: 0644]
libcore/json/src/test/java/org/json/SelfUseTest.java