Skip to content
Borislav Iordanov edited this page Jan 27, 2017 · 1 revision

Scary, Backward Incompatible Changes

  • No side-effect Json.at - The Json.at(name, def) does NOT modify the object anymore. This method returns a given property or the provided default value if the property does not exist. In previous versions, as a side effect, when the property was missing, the implementation would set its value to the provided default. This makes sense in many cases where certain layers in an application know what a default is while others don't. However, the side effect is not always desired - in particular when the Json is stored in a database, it pollutes the storage unnecessarily. Also, there are cases where the default is valid in one context but not in another, where it is important to know that the property is missing etc. A thorny issue and all around stupid decision to have a getter mutate the object as a side-effect. So from now on 'at' methods don't modify the underlying object.

Backward Compatible-ish Changes

  • Various project improvements - more tests, moved from testng to junit, some basic ones were missing and we need to add more, but also improved comments, .gitignore
  • java.io.Serializable Json class now java.io.Serializable so that application relying on Java serialization don't hit a wall trying to use Json within a serializable class.
  • **New Json.MalformedJsonException ** - Added unchecked Json.MalformedJsonException to represent JSON parsing errors. This should make it easier to catch and error problems that are specifically caused by bad JSON strings. Also parsing was improved to catch ill-formed Json.
  • Parent References - better handling of enclosing/parent Json. DAG structures can now safely constructed (instead of just trees) - the parent Json of an element will be an array in case there are multiple parents. Naturally, since an array member will have a Json array as its parent, that causes ambiguity with multiple parents. At the moment, mJson doesn't not resolve that ambiguity for the user - the application must be aware of when there are multiple parents or a single array parent.
  • Flexible Json.with - the Json.with has become more versatile now and allows for deep/recursive merging of objects and arrays. It also takes a bunch of options to drive the merging process, see https://github.com/bolerio/mjson/wiki/Deep-Merging for more information.
  • OSGi packaging - the library is now packaged as an OSGi module and can thus be used in an OSGi based application.
  • Json.factory() is now public - to obtain the current Json.Factory in effect, i.e. the one that Json.make will use, you can now call Json.factory().
  • Custom URI resolution - when processing Json schemas, one can provide a customer URI reference resolver in the Json.schema factory method. The resolver must be a implementation of Json.Function is essentially a trimmed backport of the Java 8 java.util.Function interface, and will of course disappear in subsequent versions.
  • Parsing Bug Fix - and also improved error handling during parsing
  • Validation Bug Fix - a bug arising during the validation of complex recursive schemas was fixed