Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

JSON.GetArrayItemsAsQuickList

Queries array values as QuickList.

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

Parameters

Parameter Description Example
json A JSON text or reference. "[{\"key\": 1}]"

Result

Returns quicklist refernece number or error.

Description

Queries array values as QuickList.
Creates a new QuickList and puts each JSON there into an entry of the QuickList.

See QuickList.JoinJSON function to join back the JSON.

Examples

Try the function:

Let([
list = MBS( "JSON.GetArrayItemsAsQuickList"; "[{\"id\": 1},{\"id\": 2},{\"id\": 3}]" );
text = MBS( "QuickList.GetList"; list );
r = MBS( "QuickList.Release"; list )
]; text)

Filter JSON items:

Set Variable [ $json ; Value: "[{\"id\": 1},{\"id\": 2},{\"id\": 3}]" ]
# turn into a list
Set Variable [ $list ; Value: MBS( "JSON.GetArrayItemsAsQuickList"; $json ) ]
#
# now loop over entries to filter
Set Variable [ $n ; Value: MBS( "QuickList.Count"; $list ) ]
If [ $n > 0 ]
    Loop
        # get next item
        Set Variable [ $n ; Value: $n - 1 ]
        Set Variable [ $item ; Value: MBS( "QuickList.GetValue"; $list; $n ) ]
        #
        # if meets criteria, then remove it
        If [ JSONGetElement ( $item ; "id" ) = 2 ]
            Set Variable [ $r ; Value: MBS( "QuickList.Remove"; $list; $n ) ]
        End If
        #
        # next
        Exit Loop If [ $n ≤ 0 ]
    End Loop
End If
#
Set Variable [ $json ; Value: MBS( "QuickList.JoinJSON"; $list ) ]
Show Custom Dialog [ "after filter" ; $json ]
#
Set Variable [ $r ; Value: MBS( "QuickList.Release"; $list) ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 31st May 2023, last changed 14th December 2023


JSON.GetArrayItemsAsList - JSON.GetArrayPathItems