Skip to content

Commit

Permalink
Update examples in README for v2.0.0 API
Browse files Browse the repository at this point in the history
  • Loading branch information
andyedwardsibm authored and mattbaileyuk committed Jan 7, 2023
1 parent 99717d9 commit c008688
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ Reference implementation of the [JSONata query and transformation language](http
In Node.js:

```javascript
var jsonata = require("jsonata");

var data = {
example: [
{value: 4},
{value: 7},
{value: 13}
]
const jsonata = require('jsonata');

const data = {
example: [
{value: 4},
{value: 7},
{value: 13}
]
};
var expression = jsonata("$sum(example.value)");
var result = expression.evaluate(data); // returns 24

(async () => {
const expression = jsonata('$sum(example.value)');
const result = await expression.evaluate(data); // returns 24
})()
```

In a browser:
Expand All @@ -42,9 +45,9 @@ In a browser:
<title>JSONata test</title>
<script src="https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js"></script>
<script>
function greeting() {
async function greeting() {
var json = JSON.parse(document.getElementById('json').value);
var result = jsonata('"Hello, " & name').evaluate(json);
var result = await jsonata('"Hello, " & name').evaluate(json);
document.getElementById('greeting').innerHTML = result;
}
</script>
Expand Down

0 comments on commit c008688

Please sign in to comment.