JSONUtil Versions Save

JSON generation and parsing utility library for Java.

JSONUtil-1.7

7 years ago

JSONParser now takes java.io.Reader as an input, which means it takes InputStreamReader, BufferedReader and FileReader which gives you more parsing options. Memory efficiency has been improved by not tokenizing everything before beginning the parsing of tokens. Tokens are read from the input as the parser needs them and discarded when the parser is done with them.

There's a new class called IndentPadding which when defined and added to your JSONConfig will cause the generated JSON to be formatted with one item per line and indented. This can be useful for debugging but it can also make your JSON a lot bigger. It's also possible to programmatically set a default IndentPadding in JSONConfigDefaults which will put it in all new JSONConfig objects that are created.

When writing strings or identifiers when escaping bad identifier code points is enabled, Javascript escapes which are illegal in JSON will be unescaped and possibly reescaped legally if needed. These include hex and octal character escapes and \v and '. If useECMA6 is not enabled, then ECMAScript 6 code point escapes will also be unescaped and possibly reescaped legally as needed. This will happen when writing strings even if you don't enable unescapeWherePossible.

For those that are interested in the source, JSONUtil has had a major refactoring of the code point looping code. A package private inner class named CodePointData has been created to encapsulate the redundant code used by several methods to step through a string of code points. For writeString() and escapeBadIdentifierCodePoints() it also does all of the work of handling escape pass throughs and unescaping Javascript escapes which are illegal in JSON and doing single character escapes and creating other needed escapes. This has dramatically shortened a few methods and mildly shortened the rest that are using it. Regular expression matches in arbitrary strings are now region limited to improve performance.

If you're using Java 7 or earlier, download the jars with your Java version number. Otherwise just get the regular jars that don't have a Java version in their name. They require a minimum of Java 8.

Apparently a fair number of people are using Java 5 so it is still supported.

The binaries are also available at the Maven Central Repository

JSONUtil-1.6

7 years ago

This release supports the full set of code points in identifiers permitted by the JSON standard including those which are not permitted by the ECMAScript standards. This ability is not there by default. You must enable it with JSONConfig using setFullJSONIdentifierCodePoints(boolean).

Logging can now be disabled via JNDI.

The unescape behavior has been improved when you enable "unescapeWherePossible"

escapeBadIdentifierCodePoints now properly handles Javascript escapes which are illegal in JSON as well as ECMAScript 6 code point escapes when you do not have useECMA6 enabled.

Even if you don't enable unescapeWherePossible, Javascript escapes which are illegal for JSON are now unescaped and possibly re-escaped as needed in all strings.

Many Javadoc comments have been improved.

For those playing with the build, the JUnit tests now validate most of the test JSON with both Javascript eval() and Javascript JSON.parse(). The latter is only available with Java 7 and Java 8. The script engine for Java 6 does not support JSON.parse(). Java 5 doesn't have a script engine and does no such validation in the tests.

If you're using Java 7 or earlier, download the jars with your Java version number. Otherwise just get the regular jars that don't have a Java version in their name. They require a minimum of Java 8.

Unless I hear from a significant number of people that they want Java 5 support, this will be the last release that supports Java 5. I'm thinking about dropping Java 6 as well so if you're using Java 6 and want me to keep supporting it, then let me know. Surveys I'm reading on the net are saying that Java 5 is dead and Java 6 is gasping for breath.

The binaries are also available at the Maven Central Repository

JSONUtil-1.5

8 years ago

This release fixes the bug in JSONParser which caused a parsing error when an array ended with a floating point number.

There are also a number of code readability and comments improvements.

If you're using Java 7 or earlier, download the jars with your Java version number. Otherwise just get the regular jars that don't have a Java version in their name. They require a minimum of Java 8.

The binaries are also available at the Maven Central Repository

JSONUtil-1.4

8 years ago

This release adds support for full customization of date string formats for both generation and parsing.

I have abandoned the attempt to make JSONConfig thread safe. It broke data structure loop detection through JSONAble's and the only way to fix it would be to change the JSONAble interface, which I don't want to do. It's complex enough as it is. Do not share JSONConfig objects between threads. They will break.

If you're using Java 7 or earlier, download the jars with your Java version number. Otherwise just get the regular jars that don't have a Java version in their name. They require a minimum of Java 8.

The binaries are also available at the Maven Central Repository

JSONUtil-1.3

8 years ago

This release adds two new configuration options for encoding java.util.Date objects.

Date objects can be encoded as ISO 8601 extended format strings. These can be handed directly to the new Date(String) constructor in Javascript in modern implementations of Javascript.

Date objects can alternatively be encoded as a call to the new Date(String) constructor. This is non-standard JSON and while it works in Javascript eval(), it probably won't work in most JSON parsers other than the one in JSONUtil.

The options for these both default to false. Setting one of them to true forces the other one to false.

If the JSONConfig sent to the JSON parser has either option enabled, then the parser will try to detect if a string is actually a date and if so, will return a Date object instead of a String.

The stack used for loop detection has been moved out of the JSONConfig object. This makes JSONConfig objects thread safe unless you use custom number formats, since the formats are not themselves thread safe.

JSONUtil-1.3-java7

8 years ago

JSONUtil 1.3 for Java 7

JSONUtil-1.3-java6

8 years ago

JSONUtil 1.3 for Java 6

JSONUtil-1.3-java5

8 years ago

JSONUtil 1.3 for Java5

JSONUtil-1.2

8 years ago

This release adds the JSONParser class which will parse JSON data.

It converts Javascript objects to LinkedHashMap's with the property names being the keys.

It converts Javascript arrays to ArrayList's.

It is more permissive in the data that it accepts than the JSON standard. It allows Javascript strings with either type of quote. It allows unquoted identifiers. It allows full Javascript numbers. It also allows ECMAScript 6 style code point escapes.

JSONUtil-1.2-java7

8 years ago

JSONUtil 1.2 for Java 7