Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2    Statistic    FMM    Blog  

JSON.GetArraySize

Queries the number of array entries.

Component Version macOS Windows Linux Server iOS SDK
JSON 2.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.GetArraySize"; json )   More

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"; input);
// loop over items backwards
c = MBS("JSON.GetArraySize"; j);
r = While ( [ i = c-1 ] ; i >= 0 ; [
    // query a value and if it doesn't match
    r = If( MBS( "JSON.GetPathItem"; j; i & ¶ & "land"; 1 ) <> "CH" ;
        // remove an item
        MBS( "JSON.DeleteItemFromArray"; j; i ); ""); i = i - 1 ] ; "" );
// Format and return JSON
r = MBS("JSON.Format"; j);
x = MBS("JSON.Release"; j)
]; r)

See also

Example Databases

Blog Entries

FileMaker Magazin

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


JSON.GetArrayPathItems - JSON.GetBooleanValue

Feedback: Report problem or ask question.