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 |
Example:
dim 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.
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.
- 37 properties
- property ArraySize as Integer
- property ChildNode as JSONMBS
- property Compact as Boolean New in 23.5
- property Count as Integer New in 23.5
- property Handle as Integer
- property IsArray as Boolean
- property IsBoolean as Boolean
- property IsEmpty as Boolean New in 23.5
- property IsInt64 as Boolean
- property IsNull as Boolean
- property IsNumber as Boolean
- property IsObject as Boolean
- property LastChildNode as JSONMBS
- property LastRowIndex as Integer New in 23.5
- property Name as String
- property NextNode as JSONMBS
- property PreviousNode as JSONMBS
- property Root as JSONMBS
- property Tag as Integer New in 23.5
- property toString as String
- property Type as Integer
- property TypeName as String
- property Valid as Boolean
- property Value as Variant New in 23.5
- property ValueBoolean as Boolean
- property ValueDouble as Double
- property ValueInt64 as Int64 New in 23.5
- property ValueInteger as Integer New in 23.5
- property ValueString as String
- property ValueUInt64 as UInt64 New in 23.5
- property Child(index As Integer) as JSONMBS New in 23.5
- property Child(Key As String) as JSONMBS New in 23.5
- property ChildAt(index As Integer) as JSONMBS New in 23.5
- property Operator_Subscript(index As Integer) as Variant New in 23.5
- property Value(index As Integer) as Variant New in 23.5
- property Value(Key As String) as Variant New in 23.5
- property ValueAt(index As Integer) as Variant New in 23.5
- shared property CaseSensitive as Boolean New in 23.5
- 51 methods
- method Add(Value as Variant) New in 23.5
- method AddAt(index As Integer, value As Variant) New in 23.5
- 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) New in 23.5
- method ArrayItem(index as integer, Clone as Boolean = false) as JSONMBS
- method ArrayItems(Clone as Boolean = false) as JSONMBS()
- method Clear New in 23.5
- method Clone as JSONMBS
- method Close
- method Compare(Other as JSONMBS) as Integer New in 23.5
- method Constructor
- method Constructor(dic As Dictionary) New in 23.5
- method Constructor(JSONString as String) New in 23.5
- method Constructor(other as JSONMBS) New in 23.5
- method Convert as Variant
- method DeleteItem(index as Integer)
- method DeleteItem(label as string)
- method Entries as JSONEntryMBS() New in 23.5
- method Equals(Other as JSONMBS) as Boolean
- method FilterObjectArray(Name as String, Other as JSONMBS) as JSONMBS New in 23.5
- method FindValueInArray(Other as JSONMBS, StartIndex as Integer = 0) as Integer New in 23.5
- method FindValueInObjectArray(Name as String, Other as JSONMBS, StartIndex as Integer = 0) as Integer New in 23.5
- method HasChild(label as string) as Boolean
- method HasKey(Key as string) as boolean New in 23.5
- method HasName(Name as string) as boolean New in 23.5
- method Insert(index as integer, value as variant) New in 23.5
- method Iterate as JSONIteratorMBS New in 23.5
- method IterateEntries as JSONIteratorMBS New in 23.5
- method IterateValues as JSONIteratorMBS New in 23.5
- method KeyAt(index As Integer) as String New in 23.5
- method Keys as String() New in 23.5
- method Load(JSONString as String) New in 23.5
- method Lookup(Key As String, defaultValue As Variant = nil) as Variant New in 23.5
- method Name(index As Integer) as String New in 23.5
- method NameAt(index As Integer) as String New in 23.5
- method Names as String() New in 23.5
- method Operator_Compare(Other as JSONMBS) as Integer New in 23.5
- method Operator_Convert as Variant() New in 23.5
- method Operator_Convert(dic As Dictionary) New in 23.5
- method Query(Path as string, Options as Integer = 0) as JSONMBS New in 23.5
- method Remove(Index as Integer) New in 23.5
- method Remove(Key as string) New in 23.5
- method RemoveAt(Index as Integer) New in 23.5
- method Replace(Path as string, NewValue as Variant) as JSONMBS New in 23.5
- method Search(Path as string) as JSONMBS New in 23.5
- method Sort(Reverse as boolean = false) New in 23.5
- method ToHTML(NoHeader as boolean = false, CSS as string = "") as String
- method toString(formatted as boolean) as string
- method Values as Variant() New in 23.5
- 24 shared methods
- shared method Convert(value as variant) as JSONMBS
- shared method Flatten(value as JSONMBS) as JSONMBS New in 23.5
- shared method JSONObjectCount as Integer
- shared method NewArrayNode as JSONMBS
- shared method NewBooleanNode(value as Boolean) as JSONMBS New in 23.5
- shared method NewBoolNode(value as boolean) as JSONMBS
- shared method NewCurrencyNode(value as Currency) as JSONMBS New in 23.5
- shared method NewDoubleArray(values() as Double) as JSONMBS
- shared method NewFalseNode as JSONMBS
- shared method NewInt32Array(values() as Int32) as JSONMBS New in 23.5
- shared method NewInt64Array(values() as Int64) as JSONMBS New in 23.5
- 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 New in 23.5
- shared method NewUInt64Array(values() as UInt64) as JSONMBS New in 23.5
- shared method NewUInt64Node(value as UInt64) as JSONMBS
- shared method Unflatten(value as JSONMBS) as JSONMBS New in 23.5
- 35 constants
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:
- /Java/JavaDatabase/JavaDatabase to JSON
- /MongoDB/MongoDB Blog
- /MongoDB/MongoDB Test
- /Util/JSON/JSON
- /Util/JSON/JSON Benchmark
- /Util/JSON/JSON Benchmarks
- /Util/JSON/JSON recursive search
- /Util/JSON/JSONItem clone
- /Util/RecordSet to JSON
Blog Entries
- New JSON Plugin for Xojo
- MBS Xojo Plugins, version 23.5pr1
- News from the MBS Xojo Plugins in Version 23.0
- MonkeyBread Software Releases the MBS Xojo Plugins in version 22.5
- MonkeyBread Software Releases the MBS Xojo Plugins in version 20.4
- JSON Sort
- MonkeyBread Software Releases the MBS Xojo plug-ins in version 17.0
- MBS Releases the MBS Xojo / Real Studio plug-ins in version 16.1
- JSON
- JSON - JavaScript Object Notation
Xojo Developer Magazine
- 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.5, page 35: What's New in the MBS Plugins, With the Plugins growing every year, here are new capabilities you may have missed by Stefanie Juchmes
- 17.4, page 10: News
- 16.4, page 11: News
- 15.2, page 10: News
Videos
The items on this page are in the following plugins: MBS Util Plugin.
