Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,117 @@
"using-nodejs": {
"title": "Using JSONata in a Node application",
"sidebar_label": "In NodeJS"
},
"version-1.7.0/version-1.7.0-aggregation-functions": {
"title": "Numeric aggregation functions",
"sidebar_label": "Aggregation Functions"
},
"version-1.7.0/version-1.7.0-array-functions": {
"title": "Array Functions"
},
"version-1.7.0/version-1.7.0-boolean-functions": {
"title": "Boolean functions",
"sidebar_label": "Boolean Functions"
},
"version-1.7.0/version-1.7.0-boolean-operators": {
"title": "Boolean Operators",
"sidebar_label": "Boolean Operators"
},
"version-1.7.0/version-1.7.0-comparison-operators": {
"title": "Comparison Operators",
"sidebar_label": "Comparison Operators"
},
"version-1.7.0/version-1.7.0-composition": {
"title": "Query composition",
"sidebar_label": "Query Composition"
},
"version-1.7.0/version-1.7.0-construction": {
"title": "Building result structures",
"sidebar_label": "Result Structures"
},
"version-1.7.0/version-1.7.0-contributing": {
"title": "Contributing to JSONata",
"sidebar_label": "Community and Contributing"
},
"version-1.7.0/version-1.7.0-date-time-functions": {
"title": "Date/Time functions",
"sidebar_label": "Date/Time Functions"
},
"version-1.7.0/version-1.7.0-date-time": {
"title": "Date/Time processing",
"sidebar_label": "Date/Time Processing"
},
"version-1.7.0/version-1.7.0-embedding-extending": {
"title": "Embedding and Extending JSONata",
"sidebar_label": "Embedding and Extending JSONata"
},
"version-1.7.0/version-1.7.0-expressions": {
"title": "Manipulating data with functions and expressions",
"sidebar_label": "Functions and Expressions"
},
"version-1.7.0/version-1.7.0-higher-order-functions": {
"title": "Higher order functions",
"sidebar_label": "Higher Order Functions"
},
"version-1.7.0/version-1.7.0-numeric-functions": {
"title": "Numeric functions",
"sidebar_label": "Numeric Functions"
},
"version-1.7.0/version-1.7.0-numeric-operators": {
"title": "Numeric Operators",
"sidebar_label": "Numeric Operators"
},
"version-1.7.0/version-1.7.0-object-functions": {
"title": "Object functions",
"sidebar_label": "Object Functions"
},
"version-1.7.0/version-1.7.0-other-operators": {
"title": "Other Operators",
"sidebar_label": "Other Operators"
},
"version-1.7.0/version-1.7.0-overview": {
"title": "JSONata Documentation",
"sidebar_label": "Overview"
},
"version-1.7.0/version-1.7.0-path-operators": {
"title": "Path Operators",
"sidebar_label": "Path Operators"
},
"version-1.7.0/version-1.7.0-predicate": {
"title": "Query refinement using predicate expressions",
"sidebar_label": "Predicate Queries"
},
"version-1.7.0/version-1.7.0-processing": {
"title": "The JSONata processing model",
"sidebar_label": "Processing Model"
},
"version-1.7.0/version-1.7.0-programming": {
"title": "Programming constructs",
"sidebar_label": "Functional Programming"
},
"version-1.7.0/version-1.7.0-regex": {
"title": "Using Regular Expressions",
"sidebar_label": "Regular Expressions"
},
"version-1.7.0/version-1.7.0-simple": {
"title": "Simple Queries",
"sidebar_label": "Simple Queries"
},
"version-1.7.0/version-1.7.0-sorting-grouping": {
"title": "Sorting, Grouping and Aggregation",
"sidebar_label": "Sorting, Grouping and Aggregation"
},
"version-1.7.0/version-1.7.0-string-functions": {
"title": "String functions",
"sidebar_label": "String Functions"
},
"version-1.7.0/version-1.7.0-using-browser": {
"title": "Using JSONata in a Web page",
"sidebar_label": "In a Web Page"
},
"version-1.7.0/version-1.7.0-using-nodejs": {
"title": "Using JSONata in a Node application",
"sidebar_label": "In NodeJS"
}
},
"links": {
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"rename-version": "docusaurus-rename-version"
},
"devDependencies": {
"docusaurus": "^1.6.2"
"docusaurus": "^1.14.0"
}
}
85 changes: 85 additions & 0 deletions website/pages/en/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');

const CompLibrary = require('../../core/CompLibrary');

const Container = CompLibrary.Container;

const CWD = process.cwd();

const versions = require(`${CWD}/versions.json`);

function Versions(props) {
const {config: siteConfig} = props;
const latestVersion = versions[0];
const releases = 'https://github.com/jsonata-js/jsonata/releases';
return (
<div className="docMainWrapper wrapper">
<Container className="mainContainer versionsContainer">
<div className="post">
<header className="postHeader">
<h1>{siteConfig.title} Versions</h1>
</header>
<p>New versions of this project are released every so often.</p>
<h3 id="latest">Current version (Stable)</h3>
<table className="versions">
<tbody>
<tr>
<th>{latestVersion}</th>
<td>
<a href="overview">Documentation</a>
</td>
<td>
<a href={releases + '/latest'}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
<p>
This is the current version of JSONata when installed from NPM
</p>
<h3 id="rc">Pre-release versions</h3>
<table className="versions">
<tbody>
<tr>
<th>master</th>
<td>
<a href="next/overview">Documentation</a>
</td>
</tr>
</tbody>
</table>
<p>This is the latest development version of JSONata as committed to 'master' branch. This version may be unstable.</p>
<h3 id="archive">Past Versions</h3>
<table className="versions">
<tbody>
{versions.map(
version =>
version !== latestVersion && (
<tr>
<th>{version}</th>
<td>
<a href={version + '/overview'}>Documentation</a>
</td>
<td>
<a href={releases + '/tag/v' + version}>Release Notes</a>
</td>
</tr>
),
)}
</tbody>
</table>
</div>
</Container>
</div>
);
}

module.exports = Versions;

44 changes: 44 additions & 0 deletions website/versioned_docs/version-1.7.0/aggregation-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
id: version-1.7.0-aggregation-functions
title: Numeric aggregation functions
sidebar_label: Aggregation Functions
original_id: aggregation-functions
---

## `$sum()`
__Signature:__ `$sum(array)`

Returns the arithmetic sum of an array of numbers. It is an error if the input array contains an item which isn't a number.

__Example__

- `$sum([5,1,3,7,4])` => `20`

## `$max()`
__Signature:__ `$max(array)`

Returns the maximum number in an array of numbers. It is an error if the input array contains an item which isn't a number.

__Example__

- `$max([5,1,3,7,4])` => `7`

## `$min()`
__Signature:__ `$min(array)`

Returns the minimum number in an array of numbers. It is an error if the input array contains an item which isn't a number.

__Example__

- `$min([5,1,3,7,4])` => `1`

## `$average()`
__Signature:__ `$average(array)`

Returns the mean value of an array of numbers. It is an error if the input array contains an item which isn't a number.

__Example__

- `$average([5,1,3,7,4])` => `4`


86 changes: 86 additions & 0 deletions website/versioned_docs/version-1.7.0/array-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
id: version-1.7.0-array-functions
title: Array Functions
original_id: array-functions
---

## `$count()`
__Signature:__ `$count(array)`

Returns the number of items in the `array` parameter. If the `array` parameter is not an array, but rather a value of another JSON type, then the parameter is treated as a singleton array containing that value, and this function returns `1`.

If `array` is not specified, then the context value is used as the value of `array`.

__Examples__
- `$count([1,2,3,1])` => `4`
- `$count("hello")` => 1

## `$append()`
__Signature:__ `$append(array1, array2)`

Returns and array containing the values in `array1` followed by the values in `array2`. If either parameter is not an array, then it is treated as a singleton array containing that value.

__Examples__
- `$append([1,2,3], [4,5,6])` => `[1,2,3,4,5,6]`
- `$append([1,2,3], 4)` => `[1,2,3,4]`
- `$append("Hello", "World")` => `["Hello", "World"]`


## `$sort()`
__Signature:__ `$sort(array [, function])`

Returns an array containing all the values in the `array` parameter, but sorted into order. If no `function` parameter is supplied, then the `array` parameter must contain only numbers or only strings, and they will be sorted in order of increasing number, or increasing unicode codepoint respectively.

If a comparator `function` is supplied, then is must be a function that takes two parameters:

`function(left, right)`

This function gets invoked by the sorting algorithm to compare two values `left` and `right`. If the value of `left` should be placed after the value of `right` in the desired sort order, then the function must return Boolean `true` to indicate a swap. Otherwise it must return `false`.

__Example__
```
$sort(Account.Order.Product, function($l, $r) {
$l.Description.Weight > $r.Description.Weight
})
```

This sorts the products in order of increasing weight.

The sorting algorithm is *stable* which means that values within the original array which are the same according to the comparator function will remain in the original order in the sorted array.

## `$reverse()`
__Signature:__ `$reverse(array)`

Returns an array containing all the values from the `array` parameter, but in reverse order.

__Examples__
- `$reverse(["Hello", "World"])` => `["World", "Hello"]`
- `[1..5] ~> $reverse()` => `[5, 4, 3, 2, 1]`

## `$shuffle()`
__Signature:__ `$shuffle(array)`

Returns an array containing all the values from the `array` parameter, but shuffled into random order.

__Examples__
- `$shuffle([1..9])` => `[6, 8, 2, 3, 9, 5, 1, 4, 7]`

## `$distinct()`
__Signature__ `$distinct(array)`

Returns an array containing all the values from the `array` parameter, but with any duplicates removed. Values are tested for deep equality as if by using the [equality operator](comparison-operators#equals).

__Examples__
- `$distinct([1,2,3,3,4,3,5])` => `[1, 2, 3, 4, 5]`
- `$distinct(Account.Order.Product.Description.Colour)` => `[ "Purple", "Orange", "Black" ]`

## `$zip()`
__Signature:__ `$zip(array1, ...)`

Returns a convolved (zipped) array containing grouped arrays of values from the `array1` ... `arrayN` arguments from index 0, 1, 2, etc.

This function accepts a variable number of arguments. The length of the returned array is equal to the length of the shortest array in the arguments.

__Examples__
- `$zip([1,2,3], [4,5,6])` => `[[1,4] ,[2,5], [3,6]]`
- `$zip([1,2,3],[4,5],[7,8,9])` => `[[1,4,7], [2,5,8]]`
37 changes: 37 additions & 0 deletions website/versioned_docs/version-1.7.0/boolean-functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: version-1.7.0-boolean-functions
title: Boolean functions
sidebar_label: Boolean Functions
original_id: boolean-functions
---

## `$boolean()`
__Signature:__ `$boolean(arg)`

Casts the argument to a Boolean using the following rules:

| Argument type | Result |
| ------------- | ------ |
| Boolean | unchanged |
| string: empty | `false`|
| string: non-empty | `true` |
| number: 0 | `false`|
| number: non-zero | `true` |
| null | `false`|
| array: empty | `false` |
| array: contains a member that casts to `true` | `true` |
| array: all members cast to `false` | `false` |
| object: empty | `false` |
| object: non-empty | `true` |
| function | `false` |


## `$not()`
__Signature:__ `$not(arg)`

Returns Boolean NOT on the argument. `arg` is first cast to a boolean

## `$exists()`
__Signature:__ `$exists(arg)`

Returns Boolean `true` if the arg expression evaluates to a value, or `false` if the expression does not match anything (e.g. a path to a non-existent field reference).
Loading