Platforms to show: All Mac Windows Linux Cross-Platform
Back to JSONMBS class.
JSONMBS.Load(JSONString as String)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Text should be UTF-8.
Raises an exception in case of error.
JSONMBS.Lookup(Key As String, defaultValue As Variant = nil) 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 |
Variant is converted to JSONMBS if needed.
Returns default value if key is not found.
JSONMBS.Merge(Other as JSONMBS)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 24.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
For arrays, we check if the value is already there and if not, we add it.
For objects, we check the values for each key. If it doesn't exist, we copy it over. If it exists, we check arrays and objects again, but other values just get replaced.
Raises exception if you try to merge object with array.
JSONMBS.Name(index As Integer) as String
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Raises an exception if index is out of range.
Same as NameAt or KeyAt methods.
See also:
JSONMBS.NameAt(index As Integer) as String
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Raises an exception if index is out of range.
Same as Name or KeyAt methods.
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
The order is as stored in memory currently and that order changes if you edit the JSON object.
We cache the array so multiple calls would return the same array and you should not modify it.
Same as Keys method.
JSONMBS.Operator_Compare(Other as JSONMBS) as Integer
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Called automatically by Xojo if you use =, > and < operators.
Same as Compare method.
JSONMBS.Operator_Convert 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 |
Convenience function to get all values.
Converts values to variants as needed.
Works for both objects and arrays.
Same as Values method.
See also:
JSONMBS.Operator_Convert(dic As Dictionary)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Converts all dictionary values to JSON objects internally.
See also:
JSONMBS.Operator_Subscript(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 |
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.
(Read and Write computed property)
Some examples using this property:
JSONMBS.Query(Path as string, Options as Integer = 0) as JSONMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Evaluates the root value against the JSONPath expression and returns an array of values or normalized path expressions.
Returns a JSON with an array containing either values or normalized path expressions matching the JSONPath expression, or an empty array if there is no match.
For options use kPathResultOptions* constants. Use OR to combine multiple flags.
| kPathResultOptionsValue | Return values. |
| kPathResultOptionsNoDuplicates | Remove duplicates. |
| kPathResultOptionsSort | Sort results. |
| kPathResultOptionsPath | Return paths. |
To learn more about JSONPath, please check this website:
https://goessner.net/articles/JsonPath/
Learn more about the JSONPath implementation here:
https://danielaparker.github.io/JsonCons.Net/articles/JsonPath/JsonConsJsonPath.html
See also Replace() to replace found values with new values.
JSONMBS.Remove(Index as Integer)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Works for arrays or objects.
For objects, prefer to delete by key name since removing an entry changes the order.
Same as RemoveAt method.
See also:
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Only for JSONMBS of type object.
See also:
JSONMBS.RemoveAt(Index as Integer)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Works for arrays or objects.
For objects, prefer to delete by key name since removing an entry changes the order.
Same as Remove method.
JSONMBS.Replace(Path as string, NewValue as Variant) as JSONMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Throws a JSONExceptionMBS if JSONPath evaluation fails.
Returns the modified copy of the JSON.
See also Query() function to just search without replace.
JSONMBS.Search(Path as string) as JSONMBS
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
The jmespath extension implements JMESPath. JMESPath is a query language for transforming JSON documents into other JSON documents. It's supported in both the AWS and Azure CLI and has libraries available in a number of languages.
To learn more about JMESPath, please check this website:
https://jmespath.org
See also Query() for queries with JSONPath expressions.
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 |
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 |
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 |
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 |
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 |
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 |
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)
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| method | JavaScript Object Notation | MBS Util Plugin | 23.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Convenience function to get all values.
Converts values to variants as needed.
Works for both objects and arrays.
Same as Operator_Convert method.
The items on this page are in the following plugins: MBS Util Plugin.