Skip to content

MatchingExample

Glythcing edited this page Sep 17, 2018 · 2 revisions

The following example shows the use of the exists entry point to determine whether the predicates match the input.

Given
[
  {
    "name": "tap",
    "price": 49.99,
    "quantity": 10,
    "active": true,
    "owner": null,
    "since": "2018-09-07"
  },
  {
    "name": "sink",
    "price": 99.99,
    "quantity": 100,
    "active": false,
    "owner": null,
    "since": "2018-09-02"
  }
]
When
Tranquil.parse(json).exists("quantity = 10 and name like 'ta' and owner is null")
Then

Tranquil will return: true

When
Tranquil.parse(json).exists("quantity > 10")
Then

Tranquil will return: false

Clone this wiki locally