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 |
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.
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.
- 41 properties
- property ArraySize as Integer
- property ChildNode as JSONMBS
- property Compact as Boolean
- property Count as Integer
- property Handle as Integer
- property IsArray as Boolean
- property IsBoolean as Boolean
- property IsEmpty as Boolean
- property IsInt32 as Boolean
- property IsInt64 as Boolean
- property IsNull as Boolean
- property IsNumber as Boolean
- property IsObject as Boolean
- property IsUInt32 as Boolean
- property IsUInt64 as Boolean
- property LastChildNode as JSONMBS
- property LastRowIndex as Integer
- property Name as String
- property NextNode as JSONMBS
- property PreviousNode as JSONMBS
- property Root as JSONMBS
- property Tag as Integer
- property toString as String
- property Type as Integer
- property TypeName as String
- property Valid as Boolean
- property Value as Variant
- property ValueBoolean as Boolean
- property ValueByteString as MemoryBlock
- property ValueDouble as Double
- property ValueInt64 as Int64
- property ValueInteger as Integer
- property ValueString as String
- property ValueUInt64 as UInt64
- property Child(index As Integer) as JSONMBS
- property Child(Key As String) as JSONMBS
- property ChildAt(index As Integer) as JSONMBS
- property Operator_Subscript(index As Integer) as Variant
- property Value(index As Integer) as Variant
- property Value(Key As String) as Variant
- property ValueAt(index As Integer) as Variant
- 4 shared properties
- shared property ByteStringEncoding as Integer
- shared property CaseSensitive as Boolean
- shared property LineLengthLimit as Integer
- shared property NewLineCharacters as String
- 52 methods
- method Add(Value as Variant)
- method AddAt(index As Integer, value As Variant)
- method AddItemToArray(item as JSONMBS)
- method AddItemToObject(label as string, value as JSONMBS)
- method AddOrReplaceItemToObject(label as string, value as JSONMBS)
- method Append(Value as Variant)
- method ArrayItem(index as integer, Clone as Boolean = false) as JSONMBS
- method ArrayItems(Clone as Boolean = false) as JSONMBS()
- method Clear
- method Clone as JSONMBS
- method Close
- method Compare(Other as JSONMBS) as Integer
- method Constructor
- method Constructor(dic As Dictionary)
- method Constructor(JSONString as String)
- method Constructor(other as JSONMBS)
- method Convert as Variant
- method DeleteItem(index as Integer)
- method DeleteItem(label as string)
- method Entries as JSONEntryMBS()
- method Equals(Other as JSONMBS) as Boolean
- method FilterObjectArray(Name as String, Other as JSONMBS) as JSONMBS
- method FindValueInArray(Other as JSONMBS, StartIndex as Integer = 0) as Integer
- method FindValueInObjectArray(Name as String, Other as JSONMBS, StartIndex as Integer = 0) as Integer
- method HasChild(label as string) as Boolean
- method HasKey(Key as string) as boolean
- method HasName(Name as string) as boolean
- method Insert(index as integer, value as variant)
- method Iterate as JSONIteratorMBS
- method IterateEntries as JSONIteratorMBS
- method IterateValues as JSONIteratorMBS
- method KeyAt(index As Integer) as String
- method Keys as String()
- method Load(JSONString as String)
- method Lookup(Key As String, defaultValue As Variant = nil) as Variant
- method Merge(Other as JSONMBS)
- method Name(index As Integer) as String
- method NameAt(index As Integer) as String
- method Names as String()
- method Operator_Compare(Other as JSONMBS) as Integer
- method Operator_Convert as Variant()
- method Operator_Convert(dic As Dictionary)
- method Query(Path as string, Options as Integer = 0) as JSONMBS
- method Remove(Index as Integer)
- method Remove(Key as string)
- method RemoveAt(Index as Integer)
- method Replace(Path as string, NewValue as Variant) as JSONMBS
- method Search(Path as string) as JSONMBS
- method Sort(Reverse as boolean = false)
- method ToHTML(NoHeader as boolean = false, CSS as string = "") as String
- method toString(formatted as boolean) as string
- method Values as Variant()
- 33 shared methods
- shared method ApplyMergePatch(target as JSONMBS, patch as JSONMBS) as JSONMBS
- shared method ApplyPatch(target as JSONMBS, patch as JSONMBS) as JSONMBS
- shared method Convert(value as variant) as JSONMBS
- shared method Flatten(value as JSONMBS) as JSONMBS
- shared method isValidJSON(JSON as string) as Boolean
- shared method JSONObjectCount as Integer
- shared method MergePatchFromDiff(source as JSONMBS, target as JSONMBS) as JSONMBS
- shared method NewArrayNode as JSONMBS
- shared method NewBooleanNode(value as Boolean) as JSONMBS
- shared method NewBoolNode(value as boolean) as JSONMBS
- shared method NewByteStringNode(Bytes as MemoryBlock) as JSONMBS
- shared method NewByteStringNode(Bytes as ptr, Length as UInt64) as JSONMBS
- shared method NewByteStringNode(Bytes as String) as JSONMBS
- shared method NewCurrencyNode(value as Currency) as JSONMBS
- shared method NewDoubleArray(values() as Double) as JSONMBS
- shared method NewFalseNode as JSONMBS
- shared method NewInt32Array(values() as Int32) as JSONMBS
- shared method NewInt64Array(values() as Int64) as JSONMBS
- shared method NewInt64Node(value as Int64) as JSONMBS
- shared method NewIntegerArray(values() as Integer) as JSONMBS
- shared method NewNullNode as JSONMBS
- shared method NewNumberNode(value as Double) as JSONMBS
- shared method NewNumberNode(value as string) as JSONMBS
- shared method NewObjectNode as JSONMBS
- shared method NewStringArray(values() as string) as JSONMBS
- shared method NewStringNode(value as string) as JSONMBS
- shared method NewTrueNode as JSONMBS
- shared method NewUInt32Array(values() as UInt32) as JSONMBS
- shared method NewUInt64Array(values() as UInt64) as JSONMBS
- shared method NewUInt64Node(value as UInt64) as JSONMBS
- shared method PatchFromDiff(source as JSONMBS, target as JSONMBS) as JSONMBS
- shared method PatchFromDiff(source as JSONMBS, target as JSONMBS, KeyToCopy as String) as JSONMBS
- shared method Unflatten(value as JSONMBS) as JSONMBS
- 39 constants
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:
- JSONIteratorMBS.Root as JSONMBS
- JSONMBS.ChildNode as JSONMBS
- JSONMBS.LastChildNode as JSONMBS
- JSONMBS.NextNode as JSONMBS
- JSONMBS.PreviousNode as JSONMBS
- JSONMBS.Root as JSONMBS
- JSONMBS.Child(index As Integer) as JSONMBS
- JSONMBS.Child(Key As String) as JSONMBS
- JSONMBS.ChildAt(index As Integer) as JSONMBS
Some examples using this class:
- /MongoDB/MongoDB Blog
- /MongoDB/MongoDB Test
- /Util/JSON/JSON
- /Util/JSON/JSON Benchmark
- /Util/JSON/JSON Benchmarks
- /Util/JSON/JSON Query Tests
- /Util/JSON/JSON recursive search
- /Util/JSON/JSON To HTML
- /Util/JSON/JSONItem clone
- /Util/RecordSet to JSON
Blog Entries
- MonkeyBread Software Releases the MBS Xojo Plugins in version 24.4
- MBS Xojo Plugins, version 24.4pr1
- MBS Xojo Plugins, version 24.3pr5
- News from the MBS Xojo Plugins Version 24.2
- News from the MBS Xojo Plugins Version 24.1
- Checking out Search function in JSONMBS with Xojo
- Playing with JSON Query in Xojo
- JSON Sort
- New JSONMBS methods for Xojo
- MBS Releases the MBS Xojo / Real Studio plug-ins in version 16.1
Xojo Developer Magazine
- 22.6, page 9: News
- 22.4, page 9: News
- 21.5, page 10: News
- 21.1, pages 95 to 96: A Database That Connects, A Mongo DB photo database used with FileMaker and Xojo by Stefanie Juchmes
- 19.3, page 10: News
- 18.6, page 10: News
- 17.5, page 9: News
- 17.4, page 10: News
- 16.4, page 11: News
- 15.2, page 10: News
Videos
Release notes
- Version 24.4
- Enabled new JSONMBS class to work well on Linux 32-bit.
- Version 24.3
- Version 24.2
- Version 24.1
- 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
- Version 23.1
- Fixed a crash in ToHTML method in JSONMBS class.
- Version 23.0
The items on this page are in the following plugins: MBS Util Plugin.