Skip to content

Commit 62c8679

Browse files
committed
fix(parser): support quoted members
1 parent 08f4418 commit 62c8679

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nimma",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "Scalable JSONPath engine.",
55
"keywords": [
66
"json",

src/parser/__tests__/parser.test.mjs

+8
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ describe('Parser', () => {
180180
deep: false,
181181
},
182182
]);
183+
184+
assert.deepEqual(parse("$.'application/json'"), [
185+
{
186+
type: 'MemberExpression',
187+
value: 'application/json',
188+
deep: false,
189+
},
190+
]);
183191
});
184192

185193
it('modifiers', () => {

src/parser/parser.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ function parseNumber(ctx) {
318318
function parseMember(ctx) {
319319
const { expr } = ctx;
320320
let { i } = ctx;
321+
322+
// jsonpath-plus compatibility
323+
if (isQuote(expr.charCodeAt(i))) {
324+
return parseString(ctx).slice(1, -1);
325+
}
326+
321327
const start = i;
322328
let hasOnlyDigits = true;
323329

0 commit comments

Comments
 (0)