h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
603 stars 87 forks source link

Enclose field names containing literals in quotes #61

Open mbrehler opened 3 years ago

mbrehler commented 3 years ago

When creating the text representation of a path, field names that contain lexer literals (like a period ".') should be enclosed in quotes (or brackets).

The proposed fix only adds quotes if needed (as opposed to alway). This avoids changing current paths/behavior drastically since it seems no one has run into this so far.

Change-Id: Ia6e01f9b8218182aa61d3c39b16d4bfb57e4f593

mbrehler commented 1 year ago

@michaelmior Could you please take a look at this pull request? I fixed trivial merge conflicts recently, let me know if you have other suggestions.

michaelmior commented 1 year ago

Thanks! Merged in 4c1effd23d22162d7081566accd85d755815a089

michaelmior commented 11 months ago

Looking at this more closely, there are a couple cases that aren't handled here. For example, spaces and double quotes should be enclosed in single quotes also. Single quotes should also be escaped and then quoted.