Skip to content

2. JSON syntax

The JSON syntax writes a filter as a JSON object. Its structure is inspired by MongoDB query documents, with one difference: operators start with @ instead of $, because in the LingoData family $ marks ECSON typed values.

JSON_FILTER MUST

A JSON filter MUST be a JSON object in which every key is either a field path (a condition on that field) or a logical operator: @and, @or and @nor, whose values are arrays of JSON filters, or @not, whose value is a JSON filter. Several keys in the same object are combined with and.

JSON_EMPTY_LISTS MUST

@and, @or, @nor, @in, @nin and @all with an empty array MUST make the filter fail.

JSON_EMPTY_FILTER MUST

The empty filter {} MUST match every document.

JSON_OPERATOR_OBJECT MUST

Under a field path, a JSON object whose keys all start with @ MUST be interpreted as an operator object: each key is an operator applied to the field, and several operators are combined with and. @not under a field path takes an operator object and negates it. An object mixing keys that start with @ and keys that do not MUST be rejected.

JSON_IMPLICIT_EQ MUST

Under a field path, any other value MUST be interpreted as the operand of eq.

JSON_OPERANDS_ECSON MUST

Operands MUST be decoded as ECSON values, so that typed values such as { "$date": "..." } are compared as their types and escaped keys are restored.

JSON_OPERANDS_IN_MODEL MUST

An operand that is a value outside the ECSON model (ECSON section 5.5), such as a function, MUST make the filter fail, whether the filter is evaluated, translated or converted to another representation. It MUST NOT be replaced by null or omitted.

Source: lingodata/unquery@865de91 · spec/sections/02-json-syntax.md · unquery 0.1.0 (draft)

LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.