https://github.com/sdvcrx/rejson
Reshape JSON model. WIP
https://github.com/sdvcrx/rejson
go json
Last synced: about 2 months ago
JSON representation
Reshape JSON model. WIP
- Host: GitHub
- URL: https://github.com/sdvcrx/rejson
- Owner: sdvcrx
- License: mit
- Created: 2021-01-14T14:23:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-03T14:10:32.000Z (about 4 years ago)
- Last Synced: 2025-03-23T23:44:21.153Z (2 months ago)
- Topics: go, json
- Language: Go
- Homepage: https://github.com/sdvcrx/rejson
- Size: 39.1 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rejson
> Reshape JSON model. Based on [gjson](https://github.com/tidwall/gjson) .
[](https://github.com/sdvcrx/rejson/actions)
[](https://goreportcard.com/report/github.com/sdvcrx/rejson)
[](https://codecov.io/gh/sdvcrx/rejson)
[](https://pkg.go.dev/github.com/sdvcrx/rejson)## Install
Run `go get`:
```sh
go get -u github.com/sdvcrx/rejson
```## Usage
```go
package mainimport (
"log""github.com/sdvcrx/rejson"
)type User struct {
Name string `rejson:"data.name"`
}func main() {
jsonString := `{
"code":0,
"msg": null,
"data":{"name":"John"}
}`u := User{}
rejson.Unmarshal(jsonString, &u)
log.Printf("%#v", u)
// u => User{Name:John}
}
```## Performance
Benchmark cases: [bench_test.go](https://github.com/sdvcrx/rejson/blob/master/bench_test.go)
```
BenchmarkUnmarshalReJSON-4 818850 1443 ns/op 72 B/op 4 allocs/op
BenchmarkUnmarshalGJSONGet-4 1512412 798 ns/op 0 B/op 0 allocs/op
BenchmarkUnmarshalEncodingJSON-4 312958 3785 ns/op 464 B/op 11 allocs/op
```## License
MIT