jscan
所属分类:hotest
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-06-18 19:48:52
上 传 者:
sh-1993
说明: Go的高性能JSON迭代器和验证器,
(High performance JSON iterator & validator for Go,)
文件列表:
LICENSE (1521, 2023-12-16)
bench_test.go (5218, 2023-12-16)
example_test.go (4982, 2023-12-16)
fuzz_test.go (800, 2023-12-16)
go.mod (341, 2023-12-16)
go.sum (1548, 2023-12-16)
internal/ (0, 2023-12-16)
internal/jsonnum/ (0, 2023-12-16)
internal/jsonnum/bench_test.go (1731, 2023-12-16)
internal/jsonnum/jsonnum.go (5595, 2023-12-16)
internal/jsonnum/jsonnum_test.go (7146, 2023-12-16)
internal/keyescape/ (0, 2023-12-16)
internal/keyescape/keyescape.go (4421, 2023-12-16)
internal/keyescape/keyescape_test.go (5918, 2023-12-16)
internal/strfind/ (0, 2023-12-16)
internal/strfind/strfind.go (1957, 2023-12-16)
internal/strfind/strfind_test.go (3256, 2023-12-16)
jscan.go (9431, 2023-12-16)
jscan_test.go (37358, 2023-12-16)
scan.go (17397, 2023-12-16)
testdata/ (0, 2023-12-16)
testdata/array_dec_1024_10k.json (9535, 2023-12-16)
testdata/array_int_1024_12k.json (11402, 2023-12-16)
testdata/array_nullbool_1024_5k.json (5440, 2023-12-16)
testdata/array_str_1024_639k.json (635405, 2023-12-16)
testdata/escaped_3k.json (3037, 2023-12-16)
testdata/jsontestsuite/ (0, 2023-12-16)
testdata/jsontestsuite/i_number_double_huge_neg_exp.json (14, 2023-12-16)
testdata/jsontestsuite/i_number_huge_exp.json (137, 2023-12-16)
testdata/jsontestsuite/i_number_neg_int_huge_exp.json (10, 2023-12-16)
testdata/jsontestsuite/i_number_pos_double_huge_exp.json (11, 2023-12-16)
testdata/jsontestsuite/i_number_real_neg_overflow.json (16, 2023-12-16)
testdata/jsontestsuite/i_number_real_pos_overflow.json (15, 2023-12-16)
testdata/jsontestsuite/i_number_real_underflow.json (15, 2023-12-16)
... ...
# jscan
jscan provides high-performance zero-allocation JSON iterator and validator for Go. This module doesn't provide `Marshal`/`Unmarshal` capabilities, instead it focuses on highly efficient iteration over JSON data with on-the-fly validation.
jscan is tested against https://github.com/nst/JSONTestSuite, a comprehensive test suite for [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259) compliant JSON parsers.
See [jscan-benchmark](https://github.com/romshark/jscan-benchmark) for benchmark results .
## Example
https://go.dev/play/p/moP3l9EkebF
```go
package main
import (
"fmt"
"github.com/romshark/jscan/v2"
)
func main() {
j := `{
"s": "value",
"t": true,
"f": false,
"0": null,
"n": -9.123e3,
"o0": {},
"a0": [],
"o": {
"k": "\"v\"",
"a": [
true,
null,
"item",
-67.02e9,
["foo"]
]
},
"a3": [
0,
{
"a3.a3":8
}
]
}`
err := jscan.Scan(j, func(i *jscan.Iterator[string]) (err bool) {
fmt.Printf("%q:\n", i.Pointer())
fmt.Printf("├─ valueType: %s\n", i.ValueType().String())
if k := i.Key(); k != "" {
fmt.Printf("├─ key: %q\n", k[1:len(k)-1])
}
if ai := i.ArrayIndex(); ai != -1 {
fmt.Printf("├─ arrayIndex: %d\n", ai)
}
if v := i.Value(); v != "" {
fmt.Printf("├─ value: %q\n", v)
}
fmt.Printf("└─ level: %d\n", i.Level())
return false // Resume scanning
})
if err.IsErr() {
fmt.Printf("ERR: %s\n", err)
return
}
}
```
近期下载者:
相关文件:
收藏者: