Literals which are unquoted strings not being verified for JSON syntax
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza con el script de Python proporcionado y el punto de entrada jmespath.search(), y luego compara cómo la implementación gestiona las expresiones literales con la especificación vinculada de JMESPath para literal-expressions. Confirma si los contenidos literales sin comillas deben producir un error de sintaxis y verifica el comportamiento con casos como wat, 3 y `{"foo": bar}”.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
My understanding based on the specification is that the content of a literal expression, i.e. the text between backticks, is supposed to be a valid JSON expression, otherwise it should be reported as a syntax error. The Python implementation seems to be treating them as strings instead, though. For example, this is accepted as a valid JMESPath expression:
thing == `wat`
even though I would think it should cause an error. Is this an actual bug in the Python implementation, or have I been misunderstanding the spec? (In the latter case I'd argue that the spec is misleading about this to the point of it being a documentation bug, but that's a separate issue.)
Here's a short script that demonstrates the error:
import jmespath, json, sys
literal_json = 'wat'
expression = f"thing == `{literal_json}`"
document = {"thing": "wat"}
try:
r = json.loads(literal_json)
except Exception as e:
print(f"json: parse error: {e.__class__.__name__}")
else:
print("json: no parse error")
print(f" result: {r!r}")
try:
r = jmespath.search(expression, document)
except Exception as e:
print(f"jmespath: parse error: {e.__class__.__name__}")
else:
print("jmespath: no parse error")
print(f" result: {r!r}")
It prints out the following:
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: no parse error
result: True
I would expect to see the jmespath part of the output be the same as the json part of the output, i.e. some kind of parsing error. And if I try other kinds of values, I do indeed get consistent results. For example, replacing the literal_json assignment line with literal_json = '3' gives
$ python test-jmespath.py
json: no parse error
result: 3
jmespath: no parse error
result: False
and if I replace it with literal_json = '{"foo": bar}' I get
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: parse error: LexerError
- Lenguaje dominante
- Python
- Estrellas
- 2.5k
- Forks
- 231
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de jmespath/jmespath.py
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
jmespath/jmespath.py#401 ·
-
floor() and ceil() raise OverflowError / ValueError on Infinity and NaNPosiblemente ocupada @guocn la tomó hace 48 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
jmespath/jmespath.py#381 ·
-
Lexer gives quoted identifiers an `end` that is the token length, not its end offsetPosiblemente ocupada @chiliec la tomó hace 50 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 20/100
jmespath/jmespath.py#380 ·
-
sdist is missing `tests/__init__.py`Posiblemente ocupada @deepakganesh78 la tomó hace 127 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 38/100
jmespath/jmespath.py#341 · 1 comentario ·
-
Different behavior on merge function between the JS lib and the Python libQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
jmespath/jmespath.py#329 · 1 comentario ·
Todos los issues de jmespath/jmespath.py
Issues similares
-
test_real_pandoc_failure_is_one_path_free_line fails on macOS CI with current Homebrew pandocAbiertobug TAG: unit tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
learningequality/ricecooker#898 ·
-
task
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
freelawproject/litigant-portal#1285 ·
Los mantenedores suelen responder en 2 días
-
least_squares returns a nonfinite objective for an invalid initial residualPosiblemente ocupada @sylvesterkaczmarek la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
google-deepmind/mujoco#4023 ·
Los mantenedores suelen responder en 11 días
-
Five Australian birds: Red-capped Parrot, Red-winged Fairywren, Gilbert’s Honeyeater, Western Spinebill, Western WattlebirdPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
arnegiacomo/fugleramme#427 ·
Los mantenedores suelen responder en 1 día
-
MONDO's zebu and cat Arnold-Chiari terms are is_a a dog disease (monarch-initiative/mondo#10939)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NCATSTranslator/Babel#1317 ·
Los mantenedores suelen responder en 2 días