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.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4    Statistic  

JSON.GetArrayItems

Queries entries from JSON array.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
JSON 10.4 Yes Yes Yes Yes Yes
MBS( "JSON.GetArrayItems"; json )   More

Parameters

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

Result

Returns list or error.

Description

Queries entries from JSON array.
Returns list of reference numbers for JSON objects.
Performance is better than FileMaker native once array is big enough.

Examples

Loop over JSON array items:

# get some huge JSON array
Set Variable [ $json ; Value: "[\"Hello\", \"World\"]" ]
# Create list of JSON reference numbers
Set Variable [ $list ; Value: MBS( "JSON.GetArrayItems"; $json ) ]
If [ MBS("IsError") = 0 ]
    # loop over list
    Set Variable [ $count ; Value: ValueCount($list) ]
    If [ $count > 0 ]
        Set Variable [ $index ; Value: 1 ]
        If [ $index ≤ $count ]
            Loop
                # your script steps here
                Set Variable [ $j ; Value: GetValue($list; $index) ]
                Show Custom Dialog [ "JSON item" ; MBS("JSON.Format"; $j) ]
                #
                # next
                Set Variable [ $index ; Value: $index + 1 ]
                Exit Loop If [ $index > $count ]
            End Loop
        End If
    End If
    # free them all
    Set Variable [ $r ; Value: MBS("JSON.Release"; $list) ]
End If

See also

Blog Entries

Release notes

Created 22nd August 2020, last changed 22nd August 2020


JSON.GetArrayItem   -   JSON.GetArrayItemsAsList

Feedback: Report problem or ask question.




Links
MBS FileMaker tutorial videos