Platforms to show: All Mac Windows Linux Cross-Platform

JSONMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class JavaScript Object Notation MBS Util Plugin 13.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The class for JSON object parsing and creating.
Example
Var o as JSONMBS = JSONMBS.NewObjectNode

o.AddItemToObject "Hello", JSONMBS.NewNumberNode(1)
o.AddItemToObject "World", JSONMBS.NewNumberNode(2)

MsgBox o.toString

Our JSON class

  • has a high performance.
  • is based on a modern C++ library
  • supports Xojo features like for-each loops with iterators
  • is almost compatible to the old JSONMBS class from before
  • is almost compatible to JSONItem class
  • automatically converts between variant and JSONMBS as needed.
  • reports errors with JSONException class.
  • can query, search and replace JSON values with JSON Paths.
  • can flatten and unflatten JSON.
  • can create patches and merge them back with two ways.
  • provides a lot of convenience functions.
  • can convert from JSON to/from dictionaries and arrays.
  • handles currency better and preserves digits.
  • has a lot of duplicate method/property names for API 1 and 2 compatibility and you can choose whether you prefer Append vs Add, Insert vs. AddAt or Key vs. NameAt.
  • preserves the order of object entries and allows explicit sorting.
  • can convert to HTML for displaying itself.
  • prefers case sensitive, but can optionally do case insensitive.
We can convert integer, boolean, string, double, arrays, dictionaries to JSON internally.
And convert back to variant containing integer, boolean, string, double, arrays and dictionaries.

We back ported things like GetChildNode, GetNextNode and GetPreviousNode, but those are not very efficient and you may want to move to using iterators, query values/entries/keys arrays or access items by index.

The old class is still available in a separated OldJSON Plugin for our customers for compatibility with class renamed to OldJSONMBS.

Byte String Encoding

Constant Value Description
kByteStringEncodingBase64 2 Base64 encoding
Example
kByteStringEncodingBase64URL 3 Base64 URL encoding
Example
kByteStringEncodingHex 1 Hex encoding.
Example
kByteStringEncodingNone 0 Fallback to default behavior.

Query Result Options

Constant Value Description
kPathResultOptionsNoDuplicates 1 Remove duplicates.
kPathResultOptionsPath 4 Return paths.
kPathResultOptionsSort 2 Sort results.
kPathResultOptionsValue 0 Return value.

Tags

Constant Value Description
kTagBase16 &h1a Base16 (Hex)
kTagBase64 &h1b base64
kTagBase64url &h1c base64 URL
kTagBigDec 7 Big decimal
kTagBigFloat 8 Big Float
kTagBigInt 6 Big Integer
kTagClamped &h0e clamped
kTagCode &h14 code
kTagDateTime 2 DateTime
kTagEpochMilli 4 epoch-milli
kTagEpochNano 5 epoch-nano
kTagEpochSecond 3 epoch-second
kTagExt &h11 ext
kTagFloat128 9 Float 128 bit
kTagId &h12 id
kTagMultiDimColumnMajor &h10 multi-dim-column-major
kTagMultiDimRowMajor &h0f multi-dim-row-major
kTagNone 0 n/a
kTagRegex &h13 regex
kTagUndefined 1 undefined
kTagURI &h0d URI

Types

Constant Value Description
kTypeArray 8 For an array node.
kTypeBoolean 1 For a boolean node.
kTypeByteString 7 For a byte string node.
Currently only used for MemoryBlocks passed via Variant.
kTypeDouble 5 For a double node.
kTypeInt64 2 For a Int64 node.
kTypeNull 0 For a null node.
kTypeObject 9 For a object node.
kTypeSingle 4 For a single node.
kTypeString 6 For a string node. Also applies to big numbers.
kTypeUInt64 3 For an uint64 node.

This class has no sub classes.

Some properties using for this class:

Some examples using this class:

Blog Entries

Xojo Developer Magazine

Videos

Release notes

  • Version 24.4
    • Enabled new JSONMBS class to work well on Linux 32-bit.
  • Version 24.3
    • Added isValidJSON function for JSONMBS class.
    • Improved JSONMBS class conversion from variant to convert folderitem to native path, Date & DateTime to SQLDateTime or from JSONItem objects.
  • Version 24.2
    • Added Merge function to JSONMBS class.
    • Improved ToHTML method in JSONMBS class to use CSS for right alignment.
  • Version 24.1
    • Added new variant of FromDiff method in JSONMBS class with KeyToCopy parameter to copy primary keys.
    • Fixed an edge case with Replace in JSONMBS where it didn't catch all spots.
  • Version 24.0
    • Added ApplyMergePatch, ApplyPatch, MergePatchFromDiff, PatchFromDiff to JSONMBS class.
    • Fixed an endless loop in JSONMBS class when running Search function with a bad query. Now propergates the exception properly.
    • Improved array conversion from Xojo array to JSONMBS array.
    • Improved handling of arrays for our JSON to HTML conversion for JSONMBS class.
  • Version 23.5
    • Rewrote JSONMBS class.
    • Added Search to JSONMBS class to perform JMESPath queries in Xojo.
    • Added Query and Replace functions for JSONMBS class.
    • Added ByteStringEncoding shared property to JSONMBS class.
    • Added Compact and CaseSensitive properties for JSONMBS class.
    • Added Flatten and Unflatten functions for JSONMBS class.
    • Added LineLengthLimit and NewLineCharacters shared properties to JSONMBS class.
    • Added NewByteStringNode method to JSONMBS class.
    • Added ValueByteString property in JSONMBS class.
    • Fixed an issue with JSONMBS returning single instead of double value.
    • Fixed IsInt64 property in JSONMBS class to not mark number like strings as number.
  • Version 23.3
    • Added FilterObjectArray method in JSONMBS class.
    • Improved Text property in JSONMBS class to output less commas.
  • Version 23.1
    • Fixed a crash in ToHTML method in JSONMBS class.
  • Version 23.0
    • Added Text property to JSONMBS class.
    • Fixed a crash in JSONMBS when parsing invalid JSON code, broken in 22.5pr4 while fixing another bug.

The items on this page are in the following plugins: MBS Util Plugin.


JSONIteratorMBS   -   JSValueMBS


The biggest plugin in space...