Skip to content

Commit

Permalink
fix(parser): support quoted members
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Apr 21, 2024
1 parent 08f4418 commit 62c8679
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nimma",
"version": "0.5.0",
"version": "0.6.0",
"description": "Scalable JSONPath engine.",
"keywords": [
"json",
Expand Down
8 changes: 8 additions & 0 deletions src/parser/__tests__/parser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ describe('Parser', () => {
deep: false,
},
]);

assert.deepEqual(parse("$.'application/json'"), [
{
type: 'MemberExpression',
value: 'application/json',
deep: false,
},
]);
});

it('modifiers', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/parser/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ function parseNumber(ctx) {
function parseMember(ctx) {
const { expr } = ctx;
let { i } = ctx;

// jsonpath-plus compatibility
if (isQuote(expr.charCodeAt(i))) {
return parseString(ctx).slice(1, -1);
}

const start = i;
let hasOnlyDigits = true;

Expand Down

0 comments on commit 62c8679

Please sign in to comment.