Skip to content

SimpleExample

Glythcing edited this page Sep 17, 2018 · 3 revisions

The following example shows the use of:

  • Predicates to match a single document in a JSON array
  • Projections to read a subset of the attributes in the matched document
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).read(
  "name, price, quantity",
  "quantity = 10 and name like 'ta' and owner is null"
)
Then

Tranquil will return:

{
  "name": "tap",
  "price": 49.99,
  "quantity": 10
}

Follow the links in the sidebar for more complex examples exploring the full Tranquil feature set.

Clone this wiki locally