Skip to content
Krzysztof Słysz edited this page Dec 1, 2021 · 13 revisions

Rules

The rules are use to filter data. To create a rule, you can use base fields, properties and functions. You can combine rules to create more sophisticated filter.

The "rules" node must be defined in the request body as an array of rules.

{
  "rules": []
}

Missing the rule node, null value of the rule node or an empty array is treated as no rules.
By default, rules are treated as conjunction of all rules defined in the array.
The following rules:

{
  "rules": [
    ["id", ">", 10],
    ["$.name", "==", "John"]
  ]
}

are interpretted as:

id > 10 and $.name == John

There is also possibility to set manifestly the logical operator:

{
  "rules": [
    {
      "and": [
        ["id", ">", 10],
        ["$.name", "==", "John"]
      ]
    } 		
  ]
}

The above rules are also interpretted as:

id > 10 and $.name == "John"

You can also create nested rules:

{
  "rules": [
    ["id", ">", 10],
    ["$.name", "==", "John"],
    {
      "or": [
        ["$.age", ">", 18],
	["$.address.city", "like", "New%"]
      ]
    }	
  ]
}

The above rules are interpretted as:

id > 10 and $.name == "John" and ($.age > 18 or $.address.city like "New%")

To see more examples go to Examples page

Clone this wiki locally