| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
JSON.FindValueInObjectArray
Queries index of value in object array.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| JSON | 9.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "JSON.FindValueInObjectArray"; JSON; Label; Find { ; Flags; StartIndex } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| JSON | A JSON text or reference. | "[{\"key\": 1}]" | |
| Label | The label for the value in the object to compare. | "key" | |
| Find | A JSON text or reference to find. | 1 | |
| 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 object array.Returns zero based index or -1 if not found.
We look into each object in the array, check if it has a value for the given label and compare that to the one to find.
| Flag | Value | Description |
|---|---|---|
| ByContent | 1 | Compare JSON by content, so number can be found via text. Default is off, so type counts first. |
| FindAll | 2 | Return a list of indexes instead of just the first one. |
| MatchSubstring | 4 | Match 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 item:
MBS( "JSON.FindValueInObjectArray"; "[{\"key\": 1}]"; "key"; 1 )
Example result: 0
Example result: 0
Find text:
MBS( "JSON.FindValueInObjectArray"; "[{\"key2\": \"test\"}, {\"key\": 1}]"; "key2"; "\"test\"" )
Example result: 0
Example result: 0
Find an entry in files array:
Set Variable [ $files ; Value: MBS( "JSON.GetObjectItem"; $content; "files" ) ]
# the string we look for
Set Variable [ $searchFor ; Value: MBS( "JSON.CreateString"; "something/test.jpg") ]
# now look for index in array:
Set Variable [ $index ; Value: MBS( "JSON.FindValueInObjectArray"; $files; "PathName"; $SearchFor) ]
# the string we look for
Set Variable [ $searchFor ; Value: MBS( "JSON.CreateString"; "something/test.jpg") ]
# now look for index in array:
Set Variable [ $index ; Value: MBS( "JSON.FindValueInObjectArray"; $files; "PathName"; $SearchFor) ]
See also
- FM.SQL.JSONRecords
- JSON.CreateString
- JSON.FilterObjectArray
- JSON.FindValueInArray
- JSON.GetObjectItem
Release notes
- Version 15.4
- Added flags for JSON.FindValueInArray and JSON.FindValueInObjectArray functions.
- Version 11.5
- Added StartIndex parameter to JSON.FindValueInArray and JSON.FindValueInObjectArray functions, so you can repeat search until nothing more is found.
- Version 10.0
- Added parameter to JSON.FindValueInArray and JSON.FindValueInObjectArray to compare by content.
- Version 9.0
- Added JSON.CreateValue, JSON.Equals, JSON.FindValueInArray and JSON.FindValueInObjectArray functions.
Blog Entries
- MBS FileMaker Plugin, version 15.4pr1
- MBS FileMaker Plugin, version 11.5pr2
- MBS FileMaker Plugin, version 10.0pr8
- With JSON in excellent form
- MBS FileMaker Plugin, version 8.6pr4
This function checks for a license.
Created 14th December 2018, last changed 23th July 2025