Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

JSON.ArraySlice

Slices a JSON array.

Component Version macOS Windows Linux Server iOS SDK
JSON 15.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.ArraySlice"; JSON { ; Start; end; AsReference } )   More

Parameters

Parameter Description Example Flags
JSON A JSON text or reference. [1,2,3]
Start Start position. Default is 0.
Negative numbers select from the end of the array.
0 Optional
end End position. Default is last element.
Negative numbers select from the end of the array.
If end is bigger than the array size, we stop at the end of the array.
Optional
AsReference Whether to return a reference number (1) instead of the JSON text (0).
Default is 0 for JSON text.
0 Optional

Result

Returns OK or error.

Description

Slices a JSON array.
The slice() method returns selected elements in an array, as a new array. The elements are picked from a given start, up to a (not inclusive) given end. It does not change the original array.

Examples

Slice an array:

MBS("JSON.ArraySlice"; "[\"Banana\", \"Orange\", \"Lemon\", \"Apple\", \"Mango\"]"; 1; 2)

Example result:
["Orange", "Lemon"]

Slice with negative indexes:

MBS("JSON.ArraySlice"; "[\"Banana\", \"Orange\", \"Lemon\", \"Apple\", \"Mango\"]"; -3; -1)

Example result:
["Lemon", "Apple"]

Slice with out of bounds range:

MBS("JSON.ArraySlice"; "[\"Banana\", \"Orange\", \"Lemon\", \"Apple\", \"Mango\"]"; -10; 10; 0)

Example result:
["Banana", "Orange", "Lemon", "Apple", "Mango"]

Blog Entries

This function checks for a license.

Created 8th January 2025, last changed 8th January 2025


JSON.AddValueToObject - JSON.ClearVariables