Skip to content

Commit 1f5721a

Browse files
committed
Add comparison to Javascript
1 parent 7a9e623 commit 1f5721a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

README.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
- [Types](#types)
1212
- [Operators](#operators)
1313
- [Default functions](#default-functions)
14+
- [Differences with Python and JavaScript](#differences-with-python-and-javascript)
1415
- [Differences with Python](#differences-with-python)
16+
- [Differences with JavaScript](#differences-with-javascript)
1517
- [C++ API](#c-api)
1618
- [Basic example usage](#basic-example-usage)
1719
- [Error handling](#error-handling)
@@ -28,7 +30,7 @@
2830

2931
## Introduction
3032

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:
3234
- The following types: numbers (float and integers), strings (single or double-quoted), booleans, arrays, objects.
3335
- The usual mathematical operators for numbers (`*` `/` `+` `-`), modulo (`%`) and exponentiation (`**`).
3436
- 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
129131
This list can be extended with your own functions, see below.
130132
131133
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+
132141
### Differences with Python
133142
134143
- Boolean constants are spelled `true` and `false`, not `True` and `False`.
135144
- The null/none value is spelled `null`, not `None`.
136145
- 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 `//`).
138146
- 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`.
140156
141157
142158
## C++ API

0 commit comments

Comments
 (0)