-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore support for legacy unquoted string literals
While we definitely want to transition away from unquoted string literals, it seems reasonable to do that over time, similarly to how it was handled in jmespath.py. The reason for doing so, is to allow for a simple upgrade path, where a new version of jmespath.rb can be installed, and the software using it can transition all its configuration to use the new format, and then the jmespath.rb version could be upgraded to not even support these expressions. The tests were copied verbatim from jmespath.py, and are not included in the compliance test suite, so comes with an explicit license, which the compliance test suite does not. JSON doesn't allow for comments, so I'm not sure how to handle the attribution clause of the jmespath.py license
- Loading branch information
Showing
3 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[ | ||
{ | ||
"given": { | ||
"foo": [{"name": "a"}, {"name": "b"}], | ||
"bar": {"baz": "qux"} | ||
}, | ||
"cases": [ | ||
{ | ||
"expression": "`foo`", | ||
"result": "foo" | ||
}, | ||
{ | ||
"comment": "Double quotes must be escaped.", | ||
"expression": "`foo\\\"quote`", | ||
"result": "foo\"quote" | ||
}, | ||
{ | ||
"expression": "`✓`", | ||
"result": "✓" | ||
}, | ||
{ | ||
"comment": "Double quote in literal", | ||
"expression": "`foo\\\"bar`", | ||
"result": "foo\"bar" | ||
}, | ||
{ | ||
"expression": "`1\\``", | ||
"result": "1`" | ||
}, | ||
{ | ||
"comment": "Multiple literal expressions with escapes", | ||
"expression": "`\\\\`.{a:`b`}", | ||
"result": {"a": "b"} | ||
} | ||
] | ||
}, | ||
{ | ||
"comment": "Literals", | ||
"given": {"type": "object"}, | ||
"cases": [ | ||
{ | ||
"expression": "`foo`", | ||
"result": "foo" | ||
}, | ||
{ | ||
"expression": "` foo`", | ||
"result": "foo" | ||
}, | ||
{ | ||
"comment": "Literal on RHS of subexpr not allowed", | ||
"expression": "foo.`bar`", | ||
"error": "syntax" | ||
} | ||
] | ||
} | ||
] |