JSON.GetArraySize
-----------------

Queries the number of array entries.

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

MBS( "JSON.GetArraySize"; JSON ) 

**MBS**( **"JSON.GetArraySize";** /\* Queries the number of array entries. \*/  
**$JSON**) /\* A JSON text or reference.e.g. "\[1,2,3\]" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| JSON | A JSON text or reference. | "\[1,2,3\]" |

### Result

Returns number of array entries.

### Description

Queries the number of array entries.  
### Examples

Checks number of array elements:

 MBS ( "JSON.GetArraySize"; "\[1, 2, 3, 4\]" )  
Filter items in JSON:

 Let(\[  
// input may come from caller  
input = "\[{\\"land\\": \\"CH\\"}, {\\"land\\": \\"CH\\"}, {\\"land\\": \\"DE\\"}, {\\"land\\": \\"AT\\"}, {\\"land\\": \\"CH\\"}, {\\"land\\": \\"CH\\"}\]";   
  
// parse the JSON  
j = MBS ("[JSON.Parse](JSONParse.md)"; input);  
// loop over items backwards  
c = MBS ("JSON.GetArraySize"; j);  
r = While ( \[ i = c-1 \] ; i &gt;= 0 ; \[   
 // query a value and if it doesn't match  
 r = If( MBS ( "[JSON.GetPathItem](JSONGetPathItem.md)"; j; i &amp; ¶ &amp; "land"; 1 ) &lt;&gt; "CH" ;   
 // remove an item  
 MBS ( "[JSON.DeleteItemFromArray](JSONDeleteItemFromArray.md)"; j; i ); ""); i = i - 1 \] ; "" );  
// Format and return JSON  
r = MBS ("[JSON.Format](JSONFormat.md)"; j);  
x = MBS ("[JSON.Release](JSONRelease.md)"; j)  
\]; r)  
### See also

- [FM.SQL.JSONRecords](FMSQLJSONRecords.md)
- [JSON.DeleteItemFromArray](JSONDeleteItemFromArray.md)
- [JSON.Format](JSONFormat.md)
- [JSON.GetArrayItem](JSONGetArrayItem.md)
- [JSON.GetArrayItems](JSONGetArrayItems.md)
- [JSON.GetPathItem](JSONGetPathItem.md)
- [JSON.Parse](JSONParse.md)
- [JSON.Release](JSONRelease.md)
- [Text.Styles](TextStyles.md)

### Release notes

- **Version 14.3**
    - Fixed [JSON.GetArraySize](https://www.mbsplugins.eu/JSONGetArraySize.shtml) to return no error for empty JSON and just return zero.

### Example Databases

- [Barcode/Barcode Generation JSON](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Barcode%20Generation%20JSON.shtml#9ScriptAnchor_)
- [CURL/Email/IMAP Email List](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email%20List.shtml#1ScriptAnchor_)
- [CURL/Email/IMAP Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email.shtml#1ScriptAnchor_)
- [CURL/MQTT](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/MQTT.shtml#4ScriptAnchor_)
- [JSON/JSON Benchmark](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Benchmark.shtml#5ScriptAnchor_)
- [Mac and iOS/Data Detector](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Data%20Detector.shtml#2ScriptAnchor_)
- [Mac and iOS/Machine Learning/Core Image Detection](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Machine%20Learning/Core%20Image%20Detection.shtml#1ScriptAnchor_)
- [Mac and iOS/MapKit/MapView BeeExample](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/MapView%20BeeExample.shtml#5ScriptAnchor_)
- [Mac only/ImageCapture/Camera Import](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/ImageCapture/Camera%20Import.shtml#5ScriptAnchor_)
- [Win Only/WindowsML](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/WindowsML.shtml#6ScriptAnchor_)

### Blog Entries

- [Create QR-Codes with circles](https://www.mbsplugins.de/archive/2025-02-13/Create_QR-Codes_with_circles/monkeybreadsoftware_blog_filemaker)
- [MQTT in FileMaker](https://www.mbsplugins.de/archive/2024-06-25/MQTT_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.3pr2](https://www.mbsplugins.de/archive/2024-06-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 20 - MapView](https://www.mbsplugins.de/archive/2023-12-20/MBS_Plugin_Advent_calendar_20_/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)
- [Sum up values in JSON with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2018-05-11/Sum_up_values_in_JSON_with_MBS/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [Face detection via CoreImage in FileMaker](https://www.mbsplugins.de/archive/2017-07-23/Face_detection_via_CoreImage_i/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2025, Seite 23](https://filemaker-magazin.de/neuigkeit/4286-Appetithappen-FMM_202502)
- [Ausgabe 2/2022, Seite 33](https://filemaker-magazin.de/neuigkeit/4174-Appetithappen-FMM_202202)
- [Ausgabe 5/2020, Seite 18](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function is free to use.

Created 18th August 2014 , last changed 5th November 2020

  
[JSON.GetArrayPathItems](JSONGetArrayPathItems.md) - [JSON.GetBooleanValue](JSONGetBooleanValue.md)

[HTML Version](JSONGetArraySize.shtml)