JSON.FilterObjectArray
----------------------

Filters JSON object array to find matching entries.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [13.3](newinversion133.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.FilterObjectArray"; JSON; Label; Find { ; byContent } ) 

**MBS**( **"JSON.FilterObjectArray";** /\* Filters JSON object array to find matching entries. \*/  
**$JSON**; /\* A JSON text or reference.e.g. "\[{\\"key\\": 1}\]" \*/   
**$Label**; /\* The label for the value in the object to compare.e.g. "key" \*/   
**$Find**; /\* A JSON text or reference to find.e.g. 1 \*/   
**$byContent**) /\* Optional; Compare JSON by content, so number can be found via text.  
Default is 0, so type counts first.e.g. 1 \*/ 

### 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 |  |
| byContent | Compare JSON by content, so number can be found via text.   Default is 0, so type counts first. | 1 | Optional |

### Result

Returns JSON or error.

### Description

Filters JSON object array to find matching entries.  
Similar as if you loop and look for index of matching items with [JSON.FindValueInObjectArray](JSONFindValueInObjectArray.md) and transfer it yourself to a new array.  
### Examples

Try it:

 MBS ( "JSON.FilterObjectArray"; "\[{\\"test\\":12}, {\\"test\\":123}\]"; "test"; 123 )  
<small>  
Example result:   
\[ { "test" : 123 } \] </small>Try with string:

 MBS ( "JSON.FilterObjectArray";   
"\[ {\\"test\\":\\"abc\\", \\"ID\\": 1}, {\\"test\\":\\"Hello\\", \\"ID\\": 2} \]";   
"test"; "\\"Hello\\"" )  
<small>  
Example result:   
\[ { "test" : "Hello" , "ID" : 2 } \] </small>Try same with [JSON.Query](JSONQuery.md):

 MBS ( "[JSON.Query](JSONQuery.md)";  
"\[ {\\"test\\":\\"abc\\", \\"ID\\": 1}, {\\"test\\":\\"Hello\\", \\"ID\\": 2} \]";  
"$\[?(@.test == 'Hello')\]" )  
<small>  
Example result:   
\[ { "test" : "Hello" , "ID" : 2 } \] </small>### See also

- [JSON.FindValueInObjectArray](JSONFindValueInObjectArray.md)
- [JSON.Query](JSONQuery.md)

### Release notes

- **Version 13.3**
    - Added [JSON.FilterObjectArray](https://www.mbsplugins.eu/JSONFilterObjectArray.shtml) function.

### Blog Entries

- [New in MBS FileMaker Plugin 13.3](https://www.mbsplugins.de/archive/2023-07-25/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 13.3 für Claris FileMaker](https://www.mbsplugins.de/archive/2023-07-18/Neues_MBS_Plugin_133_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.3 for Claris FileMaker](https://www.mbsplugins.de/archive/2023-07-18/MBS_Plugin_133_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.3pr1](https://www.mbsplugins.de/archive/2023-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 26th May 2023 , last changed 10th January 2024

  
[JSON.Equals](JSONEquals.md) - [JSON.FindValueInArray](JSONFindValueInArray.md)

[HTML Version](JSONFilterObjectArray.shtml)