supporting Hyphen"-" in Compile and Search
まだ誰も着手していません。
評価
調査の方向性
lexer.go から始め、特に 164-166 行付近のトークン処理と 388-392 行付近の consumeUnquotedIdentifier を確認し、その後、Search が実行される前に jmespath.Compile("foo-bar") がどのようにパースされるかを追跡してください。ハイフンを含む JSON キーに対処する意図された方法を確認し、報告された式とそれによる検索結果のカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 623
- フォーク
- 105
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
jmespath/go-jmespath のほかの issue
-
Possible error in lexer.go対応中かも @AdamMagued が 52 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 48/100
jmespath/go-jmespath#97 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
jmespath/go-jmespath#96 · コメント 1 件 ·
-
Can nested JSON string parsing be supported?対応中かも @joerodriguez が 1047 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
jmespath/go-jmespath#91 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
jmespath/go-jmespath#90 · コメント 5 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
jmespath/go-jmespath#85 · コメント 1 件 ·
jmespath/go-jmespath の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 3 日以内に返信
-
agent-execution/02 row 4: consumers Verify row lacks delivery/base binding, cannot pass post-mergeオープンbug effort:s impact:low raised-by:verifier risk:low
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
medici-finance/assay#7946 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
nwverse/persona#19269 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
console stage:spec
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tsukumogami/tsuku#2830 · コメント 1 件 ·