Version 1.0

24 july 2008
The first stable release of the wxJSON library is about to be released. I plan to release it within the next month. A major version change is the right place to do some reorganization of the API thus introducing some incompatibilities between the new version and the old 0.x versions.

Compatibility breaks

Note that there is not a 0.x compatibility feature in the new version but the incompatibilities introduced in the new version are very few and very easy to fix.

Invalid JSON objects

In versions 0.x the wxJSONTYPE_EMPTY represents an invalid (not initialized) wxJSONValue object but this is very unreadable. The right type is, of course, INVALID. So, the wxJSONTYPE_EMPTY constant will be replaced by wxJSONTYPE_INVALID and the wxJSONValue::IsEmpty() function becomes wxJSONValue::IsValid().

Integer types

In versions 0.x the wxJSONValue::IsInt64() function returns TRUE if, and only if, the stored value is of type integer and the numeric value is too large to fit in a 32-bit integer. This is wrong.
In the new version, the IsXxxxxx() functions will return TRUE if the stored value can be represented in the requested data type. So all integers can be stored in a 64-bits integer. The IsInt64() function will, therefore, return TRUE if the stored value is of type signed integer, regardless its size.

Getting values as compatible types

In versions 0.x the wxJSONValue::AsXxxxxx() functions return the value in the desired type, provided that the stored type is compatible with the one requested. For example, the wxJSONValue::AsDouble() function returns the correct value if the stored type is of type integer.
In the new version, the AsXxxxxx() functions returns the requested type without reinterpreting the bit representation of the stored value. In other words, if a JSON value contains the signed integer value of -1 (all bits set) the AsDouble() function returns a NaN (all bits sets for a double).

New features

The new features introduced in the new version of the library are contributed by wxJSON users who had modified my sources in order to meet their specific needs.
They also sent to me the modified sources so that their code can be merged in the new official release: other users might find these changes very usefull.

New integer types

The following integer data types were implemented in the new 1.0 version:

  • short and unsigned short
  • long and unsigned long
The IsShort() and IsLong() functions return TRUE if the stored value is of type signed integer and the value fits in the specified types. So, for example, if a JSON value object contains the signed integer value of 100, all the following IsXxxxxx functions return TRUE:
  • wxJSONValue::IsInt()
  • wxJSONValue::IsShort()
  • wxJSONValue::IsLong()
  • wxJSONValue::IsInt64()
To know more about this topic read the wxJSON library documentation.

New flags in the wxJSONWriter class

The wxJSONWriter class needs some more flags in order to remain compatible with the strict JSON syntax and also let the user have complete freedom about styled JSON text output.

  • wxJSONWRITER_NO_LINEFEED: this style cause the writer to not add LF between values.
  • wxJSONWRITER_ESCAPE_SOLIDUS: the solidus character (/) should only be escaped if the JSON is meant for embedding in HTML. So it is disabled by default and this flag cause that char to be escaped.
  • wxJSONWRITER_MULTILINE_STRING: this is a multiline-string mode where newlines and tabs are not escaped. This is not strict JSON, but it helps immensely when manually editing json files with multiline strings
  • wxJSONWRITER_RECOGNIZE_UNSIGNED: if a wxJSONValue object contains an unsigned integer which value is between ZERO and INT_MAX, the writer prepends a '+' (plus) sign to the JSON text output so that the reader is forced to store it in a unsigned integer value. Although the numeric value does not change, note that some other JSON parsers may fail to recognize this text.

Contributors

Many thanks to Bryan Ashby, Robbie Groenewoudt and Alexander Stigsen for their help in writing and debugging this library.