JSONMBS methods

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

Back to JSONMBS class.

Previous items

JSONMBS.Sort(Reverse as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript Object Notation MBS Util Plugin 23.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sorts values in the array by values or objects by key names.
Example
Dim o As New JSONMBS

o.add 3
o.add 4
o.Add 1

o.Sort

MessageBox o.toString(False) // shows 1,3,4

Reverse can be set to true in order to reverse the order.

JSONMBS.ToHTML(NoHeader as boolean = false, CSS as string = "") as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript Object Notation MBS Util Plugin 18.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Converts JSON to HTML.

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>"

Some examples using this method:

JSONMBS.toString(formatted as boolean) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript Object Notation MBS Util Plugin 13.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
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"}"

Returns "" on any error. Lasterror is set.

See also:

JSONMBS.Value(index As Integer) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
property JavaScript Object Notation MBS Util Plugin 23.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Get or set value at given index.
Example
Dim o As New JSONMBS

o.value(0) = "Hello"
o.value(1) = "World"
o.value(2) = "test"

MessageBox o.toString
MessageBox o.Value(1)

Variant is converted to JSONMBS if needed.
Index must be in range from 0 to Count. If index is equal to count, we append the value on setting.

If the self is an empty object, we replace it with an empty array and add the value.

Same as ValueAt or Operator_Subscript.
Raises exception if index is out of range.
(Read and Write computed property)

See also:

JSONMBS.Value(Key As String) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
property JavaScript Object Notation MBS Util Plugin 23.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Get or set a value in an object by key name.
Example
Dim c As Currency = 1.2345
dim d as Double = c

Dim j As New JSONItem
j.Value("test") = d // can't use c here!

Dim m As New JSONMBS
m.Value("test") = c

MessageBox j.ToString+EndOfLine+m.toString
// shows {"test":1.2344999999999999307} vs {"test":1.2345} since MBS stores currency exactly.

Variant is converted to or from JSONMBS if needed.
Return value as variant.
Raises an exception if the value is not found.
(Read and Write computed property)

See also:

JSONMBS.ValueAt(index As Integer) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
property JavaScript Object Notation MBS Util Plugin 23.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Get or set value at given index.
Example
Dim o As New JSONMBS

o.ValueAt(0) = "Hello"
o.ValueAt(1) = "World"
o.ValueAt(2) = "test"

MessageBox o.toString
MessageBox o.ValueAt(1)

Variant is converted to JSONMBS if needed.
Index must be in range from 0 to Count. If index is equal to count, we append the value on setting.

If the self is an empty object, we replace it with an empty array and set the value.

Same as Value or Operator_Subscript.
Raises exception if index is out of range.
(Read and Write computed property)

JSONMBS.Values as Variant()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method JavaScript Object Notation MBS Util Plugin 23.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Queries all values as an array.

Convenience function to get all values.
Converts values to variants as needed.

Works for both objects and arrays.
Same as Operator_Convert method.

Previous items

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


💬 Ask a question or report a problem