Skip to content

Commit 4dcb2bf

Browse files
committed
Updated package documentation.
1 parent cfa629c commit 4dcb2bf

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,41 @@ of your dict keys. To do this you can use either of these options:
104104
... jmespath.Options(dict_cls=collections.OrderedDict))
105105
106106
107+
JMESPath used to support a special case `json-value` syntax to represent a
108+
JSON string literal, but this was being deprecated following
109+
`JEP-12
110+
<https://github.com/jmespath-community/jmespath.spec/blob/main/jep-012-raw-string-literals.md>`__
111+
and its `raw-string` literal syntax.
112+
113+
.. code:: python
114+
115+
>>> import jmespath
116+
>>> jmespath.search("`foo`"', {})
117+
jmespath.exceptions.LexerError: Bad jmespath expression: Bad token %s `foo`:
118+
`foo`
119+
^
120+
121+
While JMESPath Community now fully deprecates this legacy syntax of providing
122+
a JSON literal string with elided double quotes, you can still opt-in to parse
123+
legacy syntax, by specifying the ``enable_legacy_literals`` flag to the
124+
``Options`` object.
125+
126+
.. code:: python
127+
128+
>>> import jmespath
129+
>>> jmespath.search("`foo`"',
130+
... mydata,
131+
... jmespath.Options(enable_legacy_literals=True))
132+
'foo'
133+
134+
135+
>>> import jmespath
136+
>>> parsed = jmespath.compile("`foo`",
137+
... jmespath.Options(enable_legacy_literals=True))
138+
>>> parsed.search(mydata)
139+
'foo'
140+
141+
107142
Custom Functions
108143
~~~~~~~~~~~~~~~~
109144

0 commit comments

Comments
 (0)