Skip to content

Commit c008688

Browse files
andyedwardsibmmattbaileyuk
authored andcommitted
Update examples in README for v2.0.0 API
1 parent 99717d9 commit c008688

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

README.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ Reference implementation of the [JSONata query and transformation language](http
1919
In Node.js:
2020

2121
```javascript
22-
var jsonata = require("jsonata");
23-
24-
var data = {
25-
example: [
26-
{value: 4},
27-
{value: 7},
28-
{value: 13}
29-
]
22+
const jsonata = require('jsonata');
23+
24+
const data = {
25+
example: [
26+
{value: 4},
27+
{value: 7},
28+
{value: 13}
29+
]
3030
};
31-
var expression = jsonata("$sum(example.value)");
32-
var result = expression.evaluate(data); // returns 24
31+
32+
(async () => {
33+
const expression = jsonata('$sum(example.value)');
34+
const result = await expression.evaluate(data); // returns 24
35+
})()
3336
```
3437

3538
In a browser:
@@ -42,9 +45,9 @@ In a browser:
4245
<title>JSONata test</title>
4346
<script src="https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js"></script>
4447
<script>
45-
function greeting() {
48+
async function greeting() {
4649
var json = JSON.parse(document.getElementById('json').value);
47-
var result = jsonata('"Hello, " & name').evaluate(json);
50+
var result = await jsonata('"Hello, " & name').evaluate(json);
4851
document.getElementById('greeting').innerHTML = result;
4952
}
5053
</script>

0 commit comments

Comments
 (0)