jmespath / jmespath/jmespath.js

Whitespace character handling

Open
#58 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
847
Forks
101
PR merge metrics
No merged PRs in 30d

Description

There is a discrepancy with how the JS library parses whitespace vs the PHP library.

```php
$p = new \JmesPath\Parser();
var_dump($p->parse("[]\r[]"));
array(3) {
["type"]=>
string(10) "projection"
["from"]=>
string(5) "array"
["children"]=>
array(2) {
[0]=>
array(2) {
["type"]=>
string(7) "flatten"
["children"]=>
array(1) {
[0]=>
array(3) {
["type"]=>
string(10) "projection"
["from"]=>
string(5) "array"
["children"]=>
array(2) {
[0]=>
array(2) {
["type"]=>
string(7) "flatten"
["children"]=>
array(1) {
[0]=>
array(1) {
["type"]=>
string(7) "current"
}
}
}
[1]=>
array(1) {
["type"]=>
string(7) "current"
}
}
}
}
}
[1]=>
array(1) {
["type"]=>
string(7) "current"
}
}
}

```

```js
jmespath.compile("[]\r[]");
jmespath.js:309 Uncaught LexerError: Unknown character:
at Lexer.tokenize (https://run.plnkr.co/preview/ck3fuluzv0006315wgzsg94tg/jmespath.js:307:31)
at Parser._loadTokens (https://run.plnkr.co/preview/ck3fuluzv0006315wgzsg94tg/jmespath.js:523:30)
at Parser.parse (https://run.plnkr.co/preview/ck3fuluzv0006315wgzsg94tg/jmespath.js:508:16)
at Object.compile (https://run.plnkr.co/preview/ck3fuluzv0006315wgzsg94tg/jmespath.js:1647:22)
at :1:10
```

It seems to me 1 of the implementations is wrong, not sure which.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.