|
11 | 11 | - [Types](#types)
|
12 | 12 | - [Operators](#operators)
|
13 | 13 | - [Default functions](#default-functions)
|
| 14 | + - [Differences with Python and JavaScript](#differences-with-python-and-javascript) |
14 | 15 | - [Differences with Python](#differences-with-python)
|
| 16 | + - [Differences with JavaScript](#differences-with-javascript) |
15 | 17 | - [C++ API](#c-api)
|
16 | 18 | - [Basic example usage](#basic-example-usage)
|
17 | 19 | - [Error handling](#error-handling)
|
|
28 | 30 |
|
29 | 31 | ## Introduction
|
30 | 32 |
|
31 |
| -Simple expression language with Python-like syntax, implemented in C++, and meant to operate on JSON values. It understands: |
| 33 | +Simple expression language with Python/JavaScript-like syntax, implemented in C++, and meant to operate on JSON values. It understands: |
32 | 34 | - The following types: numbers (float and integers), strings (single or double-quoted), booleans, arrays, objects.
|
33 | 35 | - The usual mathematical operators for numbers (`*` `/` `+` `-`), modulo (`%`) and exponentiation (`**`).
|
34 | 36 | - The usual boolean operators (`and` `or` `not`), with short-circuiting.
|
@@ -129,14 +131,28 @@ To keep the library lightweight, jsonexpr comes with only the most basic functio
|
129 | 131 | This list can be extended with your own functions, see below.
|
130 | 132 |
|
131 | 133 |
|
| 134 | +### Differences with Python and JavaScript |
| 135 | +
|
| 136 | + - The comparison operators `==` and `!=` raise an error when attempting to compare values of incompatible types (other than `null`). |
| 137 | + - When the division operation `/` is used with two integers, this results in integer division. |
| 138 | + - Bitwise operators are not implemented. |
| 139 | +
|
| 140 | +
|
132 | 141 | ### Differences with Python
|
133 | 142 |
|
134 | 143 | - Boolean constants are spelled `true` and `false`, not `True` and `False`.
|
135 | 144 | - The null/none value is spelled `null`, not `None`.
|
136 | 145 | - The return value of the modulo operation `%` has the same sign as the *left* operand (in Python, it takes the sign of the *right* operand).
|
137 |
| - - When the division operation `/` is used with two integers, this results in integer division (Python's `//`). |
138 | 146 | - The following expressions are not implemented: `a is b`, `x for x in v`, `x for x in v if c`.
|
139 |
| - - Bitwise operators are not implemented. |
| 147 | +
|
| 148 | +
|
| 149 | +### Differences with JavaScript |
| 150 | +
|
| 151 | + - Boolean operators are spelled `and`, `or`, and `not`, not `&&`, `||`, and `!`. |
| 152 | + - Array slices are spelled `a[b:c]`, not `a.slice(b, c)`. |
| 153 | + - Ternary expressions are spelled `b if a else c`, not `a ? b : c`. |
| 154 | + - Checking if a value is in an array, or a substring in a string, is spelled `b in a`, not `a.includes(b)`. |
| 155 | + - The following expressions are not implemented: `a ?? b`, `a?.b`. |
140 | 156 |
|
141 | 157 |
|
142 | 158 | ## C++ API
|
|
0 commit comments