supporting Hyphen"-" in Compile and Search
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con lexer.go, especialmente con el manejo de tokens alrededor de las líneas 164-166 y consumeUnquotedIdentifier alrededor de las líneas 388-392; después, sigue cómo se analiza jmespath.Compile("foo-bar") antes de que se ejecute Search. Confirma la forma prevista de abordar las claves JSON que contienen guiones y añade cobertura para la expresión indicada y la búsqueda resultante.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi,
I tried the below code, where we want to search jmes path having Hyphen "-", I'm getting the following error
SyntaxError: Unexpected token at the end of the expression: tNumber
From the code it looks like the Hyphen "-" is considered as a reference to get numeric values.
https://github.com/jmespath/go-jmespath/blob/3d4fd11601ddca248480565884e34e393313cd62/lexer.go#L164-L166
package main
import (
"encoding/json"
"fmt"
"github.com/jmespath/go-jmespath"
)
func main() {
var jsondata = []byte(`{"foo-bar": {"bar": "car"}}`)
var data interface{}
err := json.Unmarshal(jsondata, &data)
fmt.Println(err)
precompiled, err := jmespath.Compile("foo-bar")
if err != nil{
fmt.Println(err)
}
result, err := precompiled.Search(data)
fmt.Printf("%T", result)
fmt.Println(result, err)
}
Is it possible to pass values containing Hyphen "-"? jmespath.Compile("foo-bar")
Please let us know if there is any other way to do that, If not please consider our suggestion.
Opinion:-
Can we add a filter func in Lexer
https://github.com/jmespath/go-jmespath/blob/3d4fd11601ddca248480565884e34e393313cd62/lexer.go#L23-L29
type SkipFilterFunc func(r rune) bool
// Lexer contains information about the expression being tokenized.
type Lexer struct {
expression string // The expression provided by the user.
currentPos int // The current position in the string.
lastWidth int // The width of the current rune. This
buf bytes.Buffer // Internal buffer used for building up values.
skipFunc []SkipFilterFunc
}
https://github.com/jmespath/go-jmespath/blob/3d4fd11601ddca248480565884e34e393313cd62/lexer.go#L388-L392
And we can call those filter func inside consuleUnquotedIdentifier
if r < 0 || r > 128 || identifierTrailingBits[uint64(r)/64]&(1<<(uint64(r)%64)) == 0 {
skip := false
for _, skipFunc := range lexer.skipFunc{
if ok := skipFunc(r); ok {
skip = true
break
}
}
if skip{
continue
}
lexer.back()
break
}
So I can support any key to be part of string and can override the existing feature.
- Lenguaje dominante
- Go
- Estrellas
- 623
- Forks
- 105
- 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/go-jmespath
-
Possible error in lexer.goPosiblemente ocupada @AdamMagued la tomó hace 52 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
jmespath/go-jmespath#97 ·
-
Does jmespath support maps?Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 25/100
jmespath/go-jmespath#96 · 1 comentario ·
-
Can nested JSON string parsing be supported?Posiblemente ocupada @joerodriguez la tomó hace 1047 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
jmespath/go-jmespath#91 ·
-
Filter of comparison works wrongAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
jmespath/go-jmespath#90 · 5 comentarios ·
-
Filtering objects by dateAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
jmespath/go-jmespath#85 · 1 comentario ·
Todos los issues de jmespath/go-jmespath
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 3 días
-
agent-execution/02 row 4: consumers Verify row lacks delivery/base binding, cannot pass post-mergeAbiertobug effort:s impact:low raised-by:verifier risk:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
medici-finance/assay#7946 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
nwverse/persona#19269 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
console stage:spec
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
tsukumogami/tsuku#2830 · 1 comentario ·