As you may know we have a JSONMBS class in our MBS Xojo Util Plugin to work with JSON data. The class is optimized for best performance, but some people prefer to use native Xojo classes like dictionary for representing objects.
For the upcoming 19.2 release, we'll add new convert methods to our class. You can convert from Xojo objects to JSON and back. This involves using dictionaries for the objects and Xojo arrays for the arrays in JSON. As we don't know what is in the array, we use arrays of variants.
Convert(value as variant) as JSONMBS
This function checks what is in the variant and returns a matching JSONMBS object. String, boolean, integers and doubles are just wrapped with JSONMBS objects. Dictionaries are converted to JSON objects, but we only use text for the keys. Currency values are converted to double, colors to integers, dates and texts are converted to strings before processing them. We detect arrays of String, Object, Variant, Single, Double, Int32, Int64, Boolean and Currency and convert them to JSON arrays. Anything else can raise an exception about an unsupported type.
Convert as Variant
The counter-part function on the JSONMBS class returns the varisant matching whatever is in the JSON data. The plugin will create arrays of variant, dictionaries and values (string, double, int64, boolean and nil).
Performance on the new methods should be as good as Xojo.Core.Use Xojo.Data.ParseJSON and Xojo.Data.GenerateJSON functions in the Xojo runtime. But as we use Variant/String/Dictionary and not Auto/Text/Xojo.Core.Dictionary, this may be an interesting alternative for you?
If you like to try the new methods, please email us or wait for next prerelease.