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

JSON.FindValueInArray

Queries index of value in array.

Component Version macOS Windows Linux Server iOS SDK
JSON 9.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.FindValueInArray"; JSON; Find { ; Flags; StartIndex } )   More

Parameters

Parameter Description Example Flags
JSON A JSON text or reference. {"key": "value"}
Find A JSON text or reference to find. {"key": "value"}
Flags The sum of the flags below. Default is 0 for none.

FindAll and MatchSubstring are new in version 15.4.
0 Optional
StartIndex Index of first element to check.
Zero if not specified.
If you like to continue searching, you can pass last result + 1.
0 Optional

Added in version 11.5.

Result

Returns index or error.

Description

Queries index of value in array.
Returns zero based index or -1 if not found.

FlagValueDescription
ByContent1Compare JSON by content, so number can be found via text. Default is off, so type counts first.
FindAll2Return a list of indexes instead of just the first one.
MatchSubstring4Match text only by substring instead of whole item.

Version 10.0 or newer finds optionally by content, so number can be found via text.

Examples

Find value in an array of numbers:

MBS( "JSON.FindValueInArray"; "[5,6,7,1,4,3,7]"; 3)

Example result: 5

Find text:

MBS( "JSON.FindValueInArray"; "[\"Hello\", \"World\", \"Test\"]"; "\"World\"")

Example result: 1

Find objects:

MBS( "JSON.FindValueInArray"; "[{\"Hello\":123}, {\"World\":234}, {\"Test\":345}]"; "{\"World\":234}")

Example result: 1

Find the apple:

MBS( "JSON.FindValueInArray";
// some json with an emoji
"[\"Test\",\"🍎\",\"Other\"]";
// and we can find it with unicode escape (or by passing the emoji again)
"\"\uD83C\uDF4E\"")

Example result: 1

Find all positions of 3:

MBS( "JSON.FindValueInArray"; "[5,6,3,7,1,4,3,7]"; 3; 2)

Example result:
2
6

See also

Release notes

Blog Entries

This function checks for a license.

Created 14th December 2018, last changed 23th July 2025


JSON.FilterObjectArray - JSON.FindValueInObjectArray