jmespath / jmespath/jmespath.py

jmespath compile() function raises ParseError when provided JMESPath expression is correct

Open
#326 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.4k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

When using the **compile()** function in JMESPath with a correct expression, a ParseError is raised unexpectedly.

**Issue Details:**

- Input JSON data:
`{
"name": "John",
"last_name": "Doe"
}`

- JMESPath expression:
`join('', ['Name : 'name,' ' 'Last Name : 'last_name])`

- Error message:
`jmespath.exceptions.ParseError: Expecting: comma, got: unquoted_identifier: Parse error at column 19, token "name" (UNQUOTED_IDENTIFIER), for expression:
"join('', ['Name : 'name,' ' 'Last Name : 'last_name])`

This issue is unexpected for the following reasons:

1. The expression passes successfully when tested on the official JMESPath website.
2. The same expression compiles without errors in other programming languages such as Rust and Go.
3. The issue persists across different versions of the JMESPath module in Python, including the latest version.

**Additional information:**
Attaching an image demonstrating the successful execution of the expression on the official JMESPath website for reference.
![Screenshot 2024-04-12 135341](https://github.com/jmespath/jmespath.py/assets/92228481/afb3add7-1c89-4ac8-ab27-6a95fb1f4e77)

The **compile()** function should not raise a ParseError for the provided JMESPath expression, as it is syntactically correct and passes successfully in other contexts.
Any suggestions on how to proceed with resolving this issue are highly welcomed.

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.