Skip to content

unexpected token 'and' / 'or' for properties #72

Closed

Description

@torbenw

This works:
jsonpath.findall('$.orders', json_object)
jsonpath.findall('$.test', json_object)
jsonpath.findall('test', json_object)

This does not work:
jsonpath.findall('orders', json_object) -> JSONPathSyntaxError: unexpected token 'or', line 1, column 0
jsonpath.findall('andy', json_object) -> JSONPathSyntaxError: unexpected token 'and', line 1, column 0

According to the documentation the '$.' part is optional.

Activity

  1. added
    bug
    on Dec 9, 2024
  2. jg-rp commented on Dec 9, 2024

    @jg-rp
    Owner

    Thank you, @torbenw. Should be fixed in version 1.2.2, now released.

    Name/property selectors that match a reserved word exactly, and where we can't tell the difference using a preceding ., will still need to use quoted syntax, like ["and"]. I've added a list of the default reserved words to the docs here.

  3. torbenw commented on Dec 9, 2024

    @torbenw
    Author

    Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions