The in Operator
The in operator tests whether a value is a member of an array. It is the simplest way to check list membership in JSONata and appears throughout DAQS rules — in filter predicates, category exclusion lists, and GUID matching.
Syntax
value in array
Returns true if value is equal to any element in array, false otherwise.
In a filter predicate
$CategoryExclusion := ["OST_DetailComponents", "OST_Furniture"];
$[type = "FamilySymbol"
and $not(values.category.label in $CategoryExclusion)
]
in works directly inside [ ] filter predicates — no function call needed.
Checking parent membership
When filtering instances by a set of symbol IDs:
(
$symbolIds := $[type = "FamilySymbol" and values.assemblyCode = "21.10"].id;
$[type = "FamilyInstance" and parent.id in $symbolIds].{
"id": id,
"name": name
}
)
$symbolIds is an array of numbers. parent.id in $symbolIds checks whether the instance's parent is in that set.
Checking GUID membership
Used when filtering Parameter objects to only those relevant to the current rule:
$paramGuids := {
"NLRS_C_kwaliteitsklasse_code": "73803e29-3501-4c39-8c13-a49c4f2259d3"
};
$$[type = "Parameter" and values.guid in $paramGuids.*]
$paramGuids.* selects all values from the $paramGuids object — producing an array of GUIDs. The filter then keeps only Parameter objects whose GUID appears in that list.
in vs $arrayContains()
in |
$arrayContains() |
|
|---|---|---|
| Input | Static or variable array | Any expression |
| Works with dynamic arrays? | Yes | Yes |
| Readable | Yes | Less so |
| Standard JSONata | Yes | Custom function |
Use in whenever possible. $arrayContains() (built with $sum + $map) is only needed when in cannot be applied — for example, when testing whether an element exists in a nested or computed structure that in cannot traverse.
Common mistakes
- Using
inon a single value instead of an array —"abc" in "abc"returnsfalse; the right side must be an array - Assuming
inis case-insensitive — it is not;"OST_Doors" in ["ost_doors"]returnsfalse - Forgetting
$paramGuids.*when checking GUIDs —values.guid in $paramGuidschecks membership in the object itself (always false); you need$paramGuids.*to get the array of values