Nyzo techRelease notesNyzo 630: JSON numerical improvements

Nyzo 630: JSON numerical improvements

Nyzo version 630 (commit on GitHub) improves serialization of numerical values to JSON and deserialization of numerical values from JSON.

This version affects the documentation server and client.

In the Json.parseJsonArray() method, the '-' character is now considered as the beginning of a numerical value. This allows proper parsing of negative numbers.

RN_630 image 0

In the JsonArray class, the objects list is now marked final because the class is immutable.

RN_630 image 1

The getInteger(), getLong(), toIntegerArray(), and toLongArray() methods were added to the JsonArray class for convenience when dealing with numerical values or arrays.

RN_630 image 2

In the JsonObject.getDouble() method, more characters are now filtered out to allow a wider range of values to be easily extracted.

The JsonObject.getStringList() method, which was unused, was removed.

RN_630 image 3

In the JsonRenderer.toJson() method, numerical values are no longer wrapped in quotes.

RN_630 image 4

Also in the JsonRenderer.toJson() method, primitive int and long arrays are now serialized with the JsonRenderer.jsonForArray() method.

RN_630 image 5

The signature of the JsonRenderer.jsonForArray() method was changed to support primitive arrays.

RN_630 image 6

The JsonRenderer.isNumeric() helper method identifies values that can be safely serialized as numbers.

RN_630 image 7

The JsonTest.run() method now tests numerical arrays.

RN_630 image 8

Some cases were added to the JsonTest.testDeserialization() method to cover the changes to the JsonObject.getDouble() method.

RN_630 image 9

The JsonTest.testNumericalArrays() method calls the testIntegerArray() method and the testLongArray() method.

RN_630 image 10

The testIntegerArray() method defines an array of integers containing the minimum and maximum values that can be stored in an integer along with some values of smaller magnitude. The method serializes the array to JSON and checks that the JSON string is as expected. The method then deserializes the JSON string and checks the values against the original array.

RN_630 image 11

The testLongArray() method follows the same pattern as the testIntegerArray() method, substituting a long array and long values for the int array and int values.

RN_630 image 12