supporting Hyphen"-" in Compile and Search
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với lexer.go, đặc biệt là phần xử lý token quanh các dòng 164-166 và consumeUnquotedIdentifier quanh các dòng 388-392, sau đó theo dõi cách jmespath.Compile("foo-bar") được phân tích trước khi Search chạy. Xác nhận cách dự kiến để xử lý các khóa JSON chứa dấu gạch ngang và bổ sung coverage cho biểu thức được báo cáo cùng lookup tạo ra.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 623
- Fork
- 105
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jmespath/go-jmespath
-
Possible error in lexer.goCó thể đã có người làm @AdamMagued đã nhận 52 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
jmespath/go-jmespath#97 ·
-
Does jmespath support maps?Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
jmespath/go-jmespath#96 · 1 bình luận ·
-
Can nested JSON string parsing be supported?Có thể đã có người làm @joerodriguez đã nhận 1047 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
jmespath/go-jmespath#91 ·
-
Filter of comparison works wrongĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
jmespath/go-jmespath#90 · 5 bình luận ·
-
Filtering objects by dateĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
jmespath/go-jmespath#85 · 1 bình luận ·
Tất cả issue của jmespath/go-jmespath
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày
-
agent-execution/02 row 4: consumers Verify row lacks delivery/base binding, cannot pass post-mergeĐang mởbug effort:s impact:low raised-by:verifier risk:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
medici-finance/assay#7946 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
nwverse/persona#19269 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
console stage:spec
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tsukumogami/tsuku#2830 · 1 bình luận ·