2020-04-19 12:32:37 +03:00
|
|
|
# go-json
|
2020-04-22 07:06:52 +03:00
|
|
|
|
2020-04-26 06:12:52 +03:00
|
|
|
![Go](https://github.com/goccy/go-json/workflows/Go/badge.svg)
|
2020-05-14 16:05:25 +03:00
|
|
|
[![GoDoc](https://godoc.org/github.com/goccy/go-json?status.svg)](https://pkg.go.dev/github.com/goccy/go-json?tab=doc)
|
2020-12-30 14:23:19 +03:00
|
|
|
[![codecov](https://codecov.io/gh/goccy/go-json/branch/master/graph/badge.svg)](https://codecov.io/gh/goccy/go-json)
|
2020-04-26 06:12:52 +03:00
|
|
|
|
2020-04-19 12:32:37 +03:00
|
|
|
Fast JSON encoder/decoder compatible with encoding/json for Go
|
2020-04-19 14:27:56 +03:00
|
|
|
|
2020-09-09 11:11:28 +03:00
|
|
|
<img width="400px" src="https://user-images.githubusercontent.com/209884/92572337-42b42900-f2bf-11ea-973a-c74a359553a5.png"></img>
|
|
|
|
|
2020-08-02 11:38:04 +03:00
|
|
|
# Installation
|
2020-04-22 07:06:52 +03:00
|
|
|
|
2020-08-02 11:38:04 +03:00
|
|
|
```
|
|
|
|
go get github.com/goccy/go-json
|
|
|
|
```
|
2020-05-04 12:54:43 +03:00
|
|
|
|
2020-08-02 11:38:04 +03:00
|
|
|
# How to use
|
2020-05-04 12:54:43 +03:00
|
|
|
|
2020-08-02 11:38:04 +03:00
|
|
|
Replace import statement from `encoding/json` to `github.com/goccy/go-json`
|
2020-05-08 19:12:36 +03:00
|
|
|
|
2020-08-02 11:38:04 +03:00
|
|
|
```
|
|
|
|
-import "encoding/json"
|
|
|
|
+import "github.com/goccy/go-json"
|
|
|
|
```
|
2020-05-08 19:12:36 +03:00
|
|
|
|
2021-02-08 12:30:27 +03:00
|
|
|
# JSON library comparison
|
|
|
|
|
|
|
|
| name | encoder | decoder | compatible with `encoding/json` |
|
|
|
|
| :----: | :------: | :-----: | :-----------------------------: |
|
|
|
|
| encoding/json | ○ | ○ | N/A |
|
|
|
|
| [json-iterator/go](https://github.com/json-iterator/go) | ○ | ○ | △ |
|
|
|
|
| [easyjson](https://github.com/mailru/easyjson) | ○ | ○ | ✗ |
|
|
|
|
| [gojay](https://github.com/francoispqt/gojay) | ○ | ○ | ✗ |
|
|
|
|
| [segmentio/encoding/json](github.com/segmentio/encoding/json) | ○ | ○ | ○ |
|
|
|
|
| [jettison](github.com/wI2L/jettison) | ○ | ✗ | ✗ |
|
|
|
|
| [simdjson-go](https://github.com/minio/simdjson-go) | ✗ | ○ | ✗ |
|
|
|
|
| go-json | ○ | ○ | ○ |
|
|
|
|
|
|
|
|
- `json-iterator/go` isn't compatible with `encoding/json` in many ways, but it hasn't been supported for a long time.
|
|
|
|
|
|
|
|
|
2020-04-19 14:27:56 +03:00
|
|
|
# Benchmarks
|
|
|
|
|
|
|
|
```
|
2020-04-26 06:03:17 +03:00
|
|
|
$ cd benchmarks
|
2020-04-19 14:27:56 +03:00
|
|
|
$ go test -bench .
|
2020-04-26 06:03:17 +03:00
|
|
|
```
|
|
|
|
|
2020-08-02 11:24:39 +03:00
|
|
|
## Encode
|
2020-04-26 06:03:17 +03:00
|
|
|
|
2021-02-06 21:35:09 +03:00
|
|
|
<img width="700px" src="https://user-images.githubusercontent.com/209884/107126758-0845cb00-68f5-11eb-8db7-086fcf9bcfaa.png"></img>
|
|
|
|
<img width="700px" src="https://user-images.githubusercontent.com/209884/107126757-07ad3480-68f5-11eb-87aa-858cc5eacfcb.png"></img>
|
2020-04-26 06:03:17 +03:00
|
|
|
|
2020-08-02 11:24:39 +03:00
|
|
|
## Decode
|
|
|
|
|
2021-02-06 21:35:09 +03:00
|
|
|
<img width="700px" src="https://user-images.githubusercontent.com/209884/107126756-067c0780-68f5-11eb-938a-8bc61e3c5014.png"></img>
|
|
|
|
<img width="700px" src="https://user-images.githubusercontent.com/209884/107126754-054ada80-68f5-11eb-9f93-199f2d75bec7.png"></img>
|
|
|
|
<img width="700px" src="https://user-images.githubusercontent.com/209884/107126752-024fea00-68f5-11eb-8f63-f32844de2c99.png"></img>
|
2020-08-02 11:27:38 +03:00
|
|
|
|
2020-04-22 07:06:52 +03:00
|
|
|
# License
|
|
|
|
|
|
|
|
MIT
|