JSONUtil 1.10.2 released

JSONUtil 1.10.2 has been released. Get it here

This release changes the way that bad character data is handled. There are two types of bad character data. One is unmatched surrogates. The other is code points that are undefined by the Unicode standard (which JSONUtil uses the JDK to recognize). Previously, these were both escaped. It turns out that that was the wrong behavior. The correct behavior is to replace such characters or code points with the Unicode replacement character U+FFFD. I apologize for changing default behavior but when default behavior is wrong, it’s a bug. I have created options (described below) for those that want the old behavior back.

In reality, most applications don’t encounter bad character data, so this probably isn’t critical but I want it to be correct and I also want flexibility so JSONUtil now offers a choice of 5 different behaviors for bad character data. You can select these behaviors via JSONConfig/JSONConfigDefaults using the methods setUnmatchedSurrogatePolicy(int) and setUndefinedCodePointPolicy(int). There is also a setBadCharacterPolicy(int) method which just calls both of those two with the same value. These policies can also be set in JNDI and read/modified by the JMX Mbean

The 5 behaviors are: 0. JSONConfig.REPLACE (default) - replace the bad character(s) with the Unicode replacement character U+FFFD 1. JSONConfig.DISCARD - discard bad characters. 2. JSONConfig.EXCEPTION - throw an exception when bad character data is encountered. 3. JSONConfig.ESCAPE - escape bad characters 4. JSONConfig.PASS - pass bad characters through as if they are OK

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