Xojo Conferences
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

JSONMBS.Convert(value as variant) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 19.2 Yes Yes Yes Yes No
Function: Converts Xojo variant to JSON object.
Example:
// build some JSON:

Dim j As New JSONMBS

j.AddItemToObject "test", JSONMBS.NewNumberNode(123)
j.AddItemToObject "name", JSONMBS.NewStringNode("Joe")


// convert to Dictionary
Dim v As Variant = j.Convert

// and back
Dim o As JSONMBS = JSONMBS.Convert(v)

// show
MsgBox o.toString
Notes:
Converts values in variant to matching JSON structures.
Currency is converted to double. Color is converted to integer. Dates are converted to string.
We detect arrays of String, Object, Variant, Single, Double, Int32, Int64, Boolean and Currency and convert them to JSON arrays. Dictionaries are converted to JSON objects with texts for keys.
Anything else can raise an exception about an unsupported type.

Please note that Xojo variants don't make a difference between signed and unsigned integers, so we always convert using signed integers.

See also:

Feedback, Comments & Corrections

JSONMBS.JSONObjectCount as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 15.0 Yes Yes Yes Yes No
Function: For debugging, the plugin counts how many JSONMBS objects we have.

Feedback, Comments & Corrections

JSONMBS.NewArrayNode as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new node for an array.
Example:
dim n as JSONMBS = JSONMBS.NewArrayNode
MsgBox str(n.Type)+" = "+str(n.kTypeArray)

Feedback, Comments & Corrections

JSONMBS.NewBoolNode(value as boolean) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new boolean node.
Example:
dim j as JSONMBS = JSONMBS.NewBoolNode(true)
MsgBox j.toString

Feedback, Comments & Corrections

JSONMBS.NewDoubleArray(values() as Double) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a json array object with the given values.
Example:
dim n() as Double = array(1.0,2,3)
dim j as JSONMBS = JSONMBS.NewDoubleArray(n)
MsgBox j.toString
Notes:
This is a convenience method to quickly create an array.

Version 17.0 and newer return empty JSON array node in case of empty string array.
Older versions returned nil.

Feedback, Comments & Corrections

JSONMBS.NewFalseNode as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new false node.
Example:
dim n as JSONMBS = JSONMBS.NewFalseNode
MsgBox str(n.Type)+" = "+str(n.kTypeFalse)
Notes: This is a node which represents a boolean false value.

Feedback, Comments & Corrections

JSONMBS.NewInt64Node(value as Int64) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 17.5 Yes Yes Yes Yes No
Function: Creates a new node based on Int64 value.
Example:
dim x as int64 = 92233720368547758
dim n as JSONMBS = JSONMBS.NewInt64Node(x)

MsgBox "String: "+n.ValueString+EndOfLine+"ToString: "+n.toString+EndOfLine+"Double: "+str(n.ValueDouble,"-0")+EndOfLine+"Int64: "+str(n.ValueInteger,"-0")

Feedback, Comments & Corrections

JSONMBS.NewIntegerArray(values() as Integer) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a json array object with the given values.
Example:
dim n() as Integer = array(1,2,3)
dim j as JSONMBS = JSONMBS.NewIntegerArray(n)
MsgBox j.toString
Notes:
This is a convenience method to quickly create an array.

Version 17.0 and newer return empty JSON array node in case of empty string array.
Older versions returned nil.

Feedback, Comments & Corrections

JSONMBS.NewNullNode as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new null node.
Example:
dim n as JSONMBS = JSONMBS.NewNullNode
MsgBox str(n.Type)+" = "+str(n.kTypeNull)
Notes: This is a node which represents a nil value.

Feedback, Comments & Corrections

JSONMBS.NewNumberNode(value as Double) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new number node.
Example:
dim n as JSONMBS = JSONMBS.NewNumberNode(123)
MsgBox str(n.Type)+" = "+str(n.kTypeNumber)

See also:

Feedback, Comments & Corrections

JSONMBS.NewNumberNode(value as string) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 17.5 Yes Yes Yes Yes No
Function: Creates a new number node with given number as text.
Example:
dim n as JSONMBS = JSONMBS.NewNumberNode("92233720368547758")

MsgBox "String: "+n.ValueString+EndOfLine+"ToString: "+n.toString+EndOfLine+"Double: "+str(n.ValueDouble,"-0")+EndOfLine+"Int64: "+str(n.ValueInteger,"-0")
Notes: This allows you to control formatting of large integer and floating point values.

See also:

Feedback, Comments & Corrections

JSONMBS.NewObjectNode as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new object node.
Example:
dim n as JSONMBS = JSONMBS.NewObjectNode
MsgBox str(n.Type)+" = "+str(n.kTypeObject)

Feedback, Comments & Corrections

JSONMBS.NewStringArray(values() as string) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a json array object with the given values.
Example:
dim n() as string = array("Hello", "World")
dim j as JSONMBS = JSONMBS.NewStringArray(n)
MsgBox j.toString
Notes:
This is a convenience method to quickly create an array.

Version 17.0 and newer return empty JSON array node in case of empty string array.
Older versions returned nil.

Feedback, Comments & Corrections

JSONMBS.NewStringNode(value as string) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new string node.
Example:
// some string with single/double quote and EndOfLine
dim s as string = "Hello'World"+EndOfLine+"this is "" a test."

// make string node
dim j as JSONMBS = JSONMBS.NewStringNode(s)

// get as JSON
dim d as string = j.toString
// show
MsgBox d

// parse again
j = new JSONMBS(d)

MsgBox j.ValueString

Feedback, Comments & Corrections

JSONMBS.NewTrueNode as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates a new true node.
Example:
dim n as JSONMBS = JSONMBS.NewTrueNode
MsgBox str(n.Type)+" = "+str(n.kTypeTrue)
Notes: This is a node which represents a boolean true value.

Feedback, Comments & Corrections

JSONMBS.NewUInt64Node(value as UInt64) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
shared method JavaScript Object Notation MBS Util Plugin 18.3 Yes Yes Yes Yes No
Function: Creates a new node based on UInt64 value.
Example:
dim x as UInt64 = 92233720368547758
dim n as JSONMBS = JSONMBS.NewUInt64Node(x)

MsgBox "String: "+n.ValueString+EndOfLine+"ToString: "+n.toString+EndOfLine+"Double: "+str(n.ValueDouble,"-0")+EndOfLine+"Int64: "+str(n.ValueInteger,"-0")

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins