The JSON LotusScript Classes project was a great project but kinda slow, it parsed 15k of text in 0.5 seconds. Or 1MB of JSON in 161 seconds.

This code does that on 0.1 second, and 1 MB of JSON in under 7 seconds, making it much more useful.

Changes from the v2.4 to v2.7:
NOTE: the output has changed to be significantly easier to use and debug!

Feedback resulted in a rewrite of the generated output. The variant business was confusing when debugging, and Variants are also wasteful when storing them in lots of objects. So a new class was devised: JSONValue.
The Parse method now always returns a JSONValue object. The JSONValue object has a valueType property, which must be specified to the constructor of the JSONValue class if you create your own.
The possible values are available as constants: typeJSONNull, typeJSONFalse, typeJSONTrue, typeJSONNumber, typeJSONString, typeJSONArray, typeJSONObject.
These have been implemented as the characters n, f, t, #, S, A, O to make debugging easier.
The JSON values null, false and true are only stored as their type, a JSON number is stored in a Double, and a JSON string in a String.
The JSON Object and Array values are stored in a List of JSONValue objects.
The old JSONArray object did not have a method to access its elements. This is now provided by the method GetItemValue, which is a valid method for JSON array and object type JSONValue objects to acces their elements. Note that the array is zero based, and GetItemValue requires a Long in the range of 0..(Count-1). An error will be raised if an attempt is made to provide invalid arguments.
The JSON specification allows the name of a name/value pair in a JSON object to be the empty string. SInce a LotusScript List does not allow that, a translation is made for the name being a single double quote (cQuote constant), which is an illegal string value in the JSON specification. GetItemValue accepts an empty string and applies the translation. If a the JSON Value object for name/value pair is requested with a name that is not present an error will be raised.
The method isElement can be used to test if a name or array element is present

Stricter adherance to JSON as defined by JSON.org by:

  • the values false, true and null are not assumed if the first character is encountered. they must now be spelled correctly.
  • a name in a name/value pair in a JSON object must followed by a colon.
    The bug of an empty JSON object causing an error has been fixed.

Please report bugs and remarks. It may take a while, but I try to answer!

Changes from the original for v2.4:

earlier versions were using a base class for error reporting.
this has been reintroduced.
Also tried to clean up error reporting a bit (not too verbose).
This also cleaned up all the built up variant arrays and objects, because the error-reporing variables were clogging up the output.
Also moved more or less static objects to the base class.
Moved static members to global variables
Main change: put string into NotesStream, and read in blocks of 65534 bytes, converting them two by two (UTF16) into Longs and comparing them to constants with the Unicode codes.
At first i converted the entire string into a two dimensional array of long, but I soon realized that would lead to memory problems. Luckily the object oriented structure enabled me to switch to read the pieces on demand.

Tried to adress all the defects reported on OpenNTF

Did not do anything with the date request by Cesar Mugnatto

Main feature: Parse speed. parses 15 k JSON string in approx 100 msec, 1 MB of JSON under 7 seconds, a 23 fold performance gain!

TODO: JSONWriter classes rewrite.

I strongly suspect that a rewrite of the Writer parts to use a global stringbuilder class for all string concatenates will speed it up nicely. However, I'm pressed for time now. It will have to wait.

Basically it is just a faster version of the original JSON LotusScript Classes project, so head over there to get the rest of the documentation.