-
Notifications
You must be signed in to change notification settings - Fork 2
TransformationExample
Glythcing edited this page Sep 17, 2018
·
3 revisions
The following example shows the use of aliases and literals to transform an input. Tranquil can transform an input using:
- A subset of the attributes in the input
- Additional attributes which were not present in the input. These additional attributes may have:
- Literal values
- Derived values from string concatenation
- Derived values from simple arithmetic operations
- Attributes which were in the input but have been renamed
[
{
"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"
}
]
Tranquil.parse(json).read(
"name as pseudonym, 'gold plated ' + name as tacky, 0 as outOfStockQuantity, 2 * price as doublePrice",
"quantity = 10"
)
Tranquil will return:
{
"pseudonym": "tap",
"tacky": "gold plated tap",
"outOfStockQuantity": 0,
"doublePrice": 99.98
}