Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "." to be escaped #2

Closed
mtdowling opened this issue Jul 6, 2013 · 2 comments
Closed

Allow "." to be escaped #2

mtdowling opened this issue Jul 6, 2013 · 2 comments
Labels

Comments

@mtdowling
Copy link
Contributor

A lot of JSON keys contain dots. I suggest adding a "" escape character for dots to allow them embedded within keys.

@mtdowling
Copy link
Contributor Author

Actually, I think "" should be added an escape character for any special character. I think the regex for an identifier should be expanded to match the JSON spec (which means we need to allow the special characters for JamesPath expressions to be escaped).

@jamesls
Copy link
Member

jamesls commented Jul 8, 2013

I think we should match most, but not all, of the JSON spec. Given that JSON strings must be enclosed with " chars, there are some things that don't work as well (namely whitespace chars). I'd also like to reserve most of the non [a-zA-Z0-9] chars for future use, which will allow jmespath to remain backwards compatible if new constructs are added. I'd propose the following slightly modified grammar for an identifier (using the same ABNF form as the JSON spec):

    identifier        = *char
    char              = unescaped /
                        escape (
                            %x20-2F /    ; Space,!,",#,$,%,&,',(,),*,+,comma,-,.,/
                            %x3A-40 /    ; :,;,<,=,>,?,@
                            %x5B    /    ; Left bracket: [
                            %x5C    /    ; Back slash: \
                            %x5D    /    ; Right bracket: ]
                            %x5E    /    ; Caret: ^
                            %x60    /    ; Backtick: `
                            %x7B-7E /    ; {,|,},~
                            b       /    ; backspace
                            n       /    ; new line
                            f       /    ; form feed
                            r       /    ; carriage return
                            t       )    ; tab
    escape            = %x5C   ; Back slash: \
    unescaped         = %x30-39 / %x41-5A / %x5F / %x61-7A / %x7F-10FFFF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants