JSON Conditions

Schema

{
  "operator": "string",
  "path": "string",
  "case_sensitive": true|false,
  "default": true|false,
  "value": "any",
  "value_path": "string",
  "value_type": "string",
  "match_type": "all|any",
  "conditions": [ 
    {}
  ]
}

Fields

operator (Required)

Specifies the logical or comparison operation to perform.

OperatorDescription
andAll child conditions must be true. If no children, evaluates to false.
orAt least one child condition must be true. If no children, evaluates to true.
notNegates the result of its single child condition. If no children, evaluates to false.
eq(Equals) The value at path must be equal to value.
ne(Not Equals) The value at path must not be equal to value.
gt(Greater Than) The value at path must be greater than value.
gte(Greater Than or Equal) The value at path must be greater than or equal to value.
lt(Less Than) The value at path must be less than value.
lte(Less Than or Equal) The value at path must be less than or equal to value.
matchThe string value at path must match the regular expression provided in value.
existsThe JSON path specified in path must exist in the document.
treeApplies child conditions to a subtree identified by path.
istypeThe JSON element at path must be of the type specified in value (e.g., "string", "integer", "array").
countThe number of elements at path must be equal to value.
countltThe number of elements at path must be less than value.
countgtThe number of elements at path must be greater than value.
inThe value at path must be present in the array specified by value.
isnullThe value at path must be null.
isnotnullThe value at path must not be null.

conditions

A list of child conditions. Used with logical operators (and, or, not, tree).


path

The dot notation JSON path pointing to the element(s) in the document to evaluate, e.g. user.address.city or items[*].price


value

The value to compare against the document's data at path. The type should align with value_type.


value_path

An alternative to value. If specified, the value to compare against will be dynamically retrieved from the document itself using this dot notation JSON path.


value_type

Specifies the data type for comparison; values are

ValueDescription
stringCompares values as strings.
numberCompares values as numbers (integers or floats).
dateCompares values as dates. Dates should be in ISO 8601 format.
boolCompares values as booleans.

case_sensitive

If true, string comparisons (e.g., eq, ne, match) will be case-sensitive.


match_type

When path resolves to multiple tokens (e.g. an array), this defines how the condition is applied.

  • all: The condition must be true for all resolved tokens.
  • any: The condition must be true for at least one resolved token.

default

If true, and the path does not exist, the condition will evaluate to true. This is useful for providing default behavior when data is optional.


Examples

Simple Equality Check

Match documents where status is active.

{
  "operator": "eq",  
  "path": "status",
  "value": "active",
  "case_sensitive": false
}

Logical AND

Match documents where category is "electronics" AND price is greater than 500.

{
  "operator": "amd",
  "conditions": [
    {
      "operator": "eq",  
      "path": "category",
      "value": "electronics",
      "case_sensitive": false
    },
    {
      "operator": "gt",  
      "path": "price",
      "value": 500,
      "value_type": "number"
    }
  ]
}

Logical OR with Case-Insensitive Match

Match documents where tag is urgent (case-insensitive) OR priority is high.

{
  "operator": "or",
  "conditions": [
    {
      "operator": "eq",  
      "path": "tag",
      "value": "urgent",
      "case_sensitive": false
    },
    {
      "operator": "eq",  
      "path": "priority",
      "value": "high",
      "case_sensitive": false
    }
  ]
}

Existence Check

Match documents that have a metadata.timestamp field.

{
  "operator": "exists",
  "path": "metadata.timestamp",
}

Regular Expression Match

Match documents where product_code starts with "ABC-".

{
  "condition": "match",
  "path": "product_code",
  "value": "^ABC-.*$",
  "case_sensitive": false
}

Array Element Matching (match_type)

Match documents where any item in the tags array is "featured".

{
  "operator": "eq",
  "path": "tags[*]",
  "value": "featured",
  "match_type": "any"
}

Dynamic Value Comparison (value_path)

Match documents where item.price is greater than item.cost.

{
  "operator": "gt",
  "path": "item.price",
  "value_path": "item.cost",
  "value_type": "number"
}

Count Operator

Match documents where the $.items array has exactly 3 elements.

{
  "operator": "count",
  "path": "items",
  "value": 3,
  "value_type": "number"
}

IsNull

Match documents where description is null.

{
  "operator": "isnull",
  "path": "description"
}