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

JSON.FilterObjectArray

Filters JSON object array to find matching entries.

Component Version macOS Windows Linux Server iOS SDK
JSON 13.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.FilterObjectArray"; json; Label; find { ; byContent } )   More

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 and transfer it yourself to a new array.

Examples

Try it:

MBS( "JSON.FilterObjectArray"; "[{\"test\":12}, {\"test\":123}]"; "test"; 123 )

Example result:
[ { "test": 123 } ]

Try with string:

MBS( "JSON.FilterObjectArray";
"[ {\"test\":\"abc\", \"ID\": 1}, {\"test\":\"Hello\", \"ID\": 2} ]";
"test"; "\"Hello\"" )

Example result:
[ { "test": "Hello", "ID": 2 } ]

Try same with JSON.Query:

MBS( "JSON.Query";
"[ {\"test\":\"abc\", \"ID\": 1}, {\"test\":\"Hello\", \"ID\": 2} ]";
"$[?(@.test == 'Hello')]" )

Example result:
[ { "test": "Hello", "ID": 2 } ]

See also

Release notes

Blog Entries

This function checks for a license.

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


JSON.Equals - JSON.FindValueInArray