Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

JSONMBS.AddItemToArray(item as JSONMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Adds an item to an array.
Notes:
If you add item from new nodes created with plugin, we add them to the tree.
If you add items from existing node from other JSON tree, we add references.

Feedback, Comments & Corrections

JSONMBS.AddItemToObject(label as string, value as JSONMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Adds an item to an object with given label.
Notes:
If you add item from new nodes created with plugin, we add them to the tree.
If you add items from existing node from other JSON tree, we add references.

Feedback, Comments & Corrections

JSONMBS.ArrayItem(index as Integer) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Queries array item with given index.

Feedback, Comments & Corrections

JSONMBS.Child(label as string) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Returns the Child node for the node with the given label.
Example:
dim jv as JSONMBS = JSONMBS.NewStringNode("value")
dim jo as JSONMBS = JSONMBS.NewObjectNode

jo.AddItemToObject("key", jv)

// shows {"key": "value"}
MsgBox jo.toString
MsgBox jo.Child("key").ValueString
Notes: Similar to JSONItem.Child()

Feedback, Comments & Corrections

JSONMBS.Clone as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 16.0 Yes Yes Yes Yes No
Function: Clones the JSON tree.

Feedback, Comments & Corrections

JSONMBS.Close
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 16.0 Yes Yes Yes Yes No
Function: Frees node.
Notes:
No need to call this as destructor does the same.
But this call allows you to release circular references.

Feedback, Comments & Corrections

JSONMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Creates an empty object.
Notes: Lasterror is set.

See also:

Feedback, Comments & Corrections

JSONMBS.Constructor(text as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Parses the given JSON String into the tree where this node is the root.
Example:
dim o as new JSONMBS("{""text"":""Hello World""}")
MsgBox o.toString
Notes:
Lasterror is set.
Text should be UTF-8.

Starting with version 15.0, you may see a ParseError and still have all the content which was parsed until that error.

See also:

Feedback, Comments & Corrections

JSONMBS.hasChild(label as string) as Boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.5 Yes Yes Yes Yes No
Function: Checks if a child node for the node with the given label exists.
Example:
dim jv as JSONMBS = JSONMBS.NewStringNode("value")
dim jo as JSONMBS = JSONMBS.NewObjectNode

jo.AddItemToObject("key", jv)

// shows {"key": "value"}
MsgBox jo.toString
MsgBox str(jo.hasChild("key"))
Notes: Similar to JSONMBS.Child(), but without returning the actual objct.

Feedback, Comments & Corrections

JSONMBS.SuffixObject(nextItem as JSONMBS) as JSONMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.5 Yes Yes Yes Yes No
Function: Appends an array item on a previous item in the same array.
Example:
// test code for SuffixObject:
const UseFastMode = true

dim o as JSONMBS = JSONMBS.NewArrayNode

dim startTime as Double = Microseconds
dim last as JSONMBS
for i as Integer = 0 to 10000

dim j as JSONMBS = JSONMBS.NewStringNode("test" + str(i))

#if UseFastMode = False
// slow
o.AddItemToArray(j)

#else
// 10 times faster

if last = nil then
o.AddItemToArray(j)
last = o.ChildNode
else
last = last.SuffixObject(j)
end if
#endif
next

dim endTime as Double = Microseconds

MsgBox (str(endTime - startTime))
Notes:
This method is an optimization for AddItemToArray.
You can call SuffixObject only on the last item of an array to add another one.
Only add new nodes there.
Any other use could lead into crashes or memory leaks.

Returns in version 16.0 and newer the new reference node.

Feedback, Comments & Corrections

JSONMBS.ToHTML(NoHeader as boolean = false, CSS as string = "") as String
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 18.2 Yes Yes Yes Yes No
Function: Converts JSON to HTML.
Notes:
We build for you a HTML with tables for each array and object. We include values and tag rows with even/odd CSS classes.
If NoHeader is true, you get just the raw table without header/footer.
Anything in CSS parameter is inserted before the table.
Returns HTML, which can be loaded in htmlviewer.

Example for CSS to do even/odd line backgrounds:

/* CSS style to include */
"<style>
td
{
vertical-align:top;
}

.odd
{
background-color: white;
}

.even
{
background-color: #DDD;
}
</style>"

Feedback, Comments & Corrections

JSONMBS.toString(formatted as boolean) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method JavaScript Object Notation MBS Util Plugin 13.3 Yes Yes Yes Yes No
Function: Produces a JSON markup text document from a document tree.
Example:
dim o as JSONMBS = JSONMBS.NewObjectNode

o.AddItemToObject "text", JSONMBS.NewStringNode("Hello World")

MsgBox o.toString // shows "{"text":"Hello World"}"
Notes: Returns "" on any error. Lasterror is set.

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins