dchester / jsonpath

Query and manipulate JavaScript objects with JSONPath expressions. Robust JSONPath engine for Node.js.
MIT License
1.35k stars 216 forks source link

querying throws an error if the key in the object starts with a number. #190

Open clifrocks311 opened 1 month ago

clifrocks311 commented 1 month ago

this is the error I am receiving:

"errors": [ { "message": "Parse error on line 1:\n...ls[0].rateOfReturn.9mCNoload\n-----------------------^\nExpecting 'DOT', 'DOT_DOT', '[', got 'IDENTIFIER'", "name": "Error", "stack": "Error: Parse error on line 1:\n...ls[0].rateOfReturn.9mCNoload\n-----------------------^\nExpecting 'DOT', 'DOT_DOT', '[', got 'IDENTIFIER'\n at Parser.parseError (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/generated/parser.js:166:15)\n at Parser.parser.yy.parseError (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/lib/parser.js:13:17)\n at Parser.parse (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/generated/parser.js:224:22)\n at JSONPath._normalize (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/lib/index.js:198:24)\n at JSONPath.stringify (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/lib/index.js:168:15)\n at JSONPath.value (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/jsonpath/lib/index.js:63:31)\n at modifyResponsePayload (/Users/cxho3/Sandbox/service-virtualization-framework/lib/util/modifyGetResultset.js:898:30)\n at Object.selectFromDB (/Users/cxho3/Sandbox/service-virtualization-framework/lib/util/modifyGetResultset.js:1069:27)\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async virtualizeAPI (eval at (/Users/cxho3/Sandbox/service-virtualization-framework/node_modules/mountebank/src/models/responseResolver.js:63:34), :165:58)" } ] }

here is the object I am passing in: { return { statusCode: 200, headers: { "Content-Type": "application/json" }, body: { "entityId": "a6c93fd4-bf67-b8666eea3232", "entityName": "CanaFund", "sourceEntityId": 21168, "sourceEntityName": "CanaFund", "source": "Eagle", "asOfDate": "2021-07-15", "returnDetails": [ { "shareClass": "Class C", "rateOfReturn": { "name": "clifton", "address": "string", "5dCLoad": "five string", "5dCNoload": "string", "7dCLoad": "string", "7dCNoload": "string", "1mCLoad": "string", "1mCNoload": "string", "3mCLoad": "string", "3mCNoload": "string", "6mCLoad": "string", "6mCNoload": "string", "9mCLoad": "string", "9mCNoload": "string", "1yCLoad": "string", "1yCNoload": "string",

looks like if the key starts with a number, it is now able to parse correctly? Any suggestions?