go-json/README.md

122 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

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-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-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
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
2020-08-02 11:24:39 +03:00
**Fastest**
2020-04-26 06:03:17 +03:00
### SmallStruct
2020-08-02 11:27:38 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118973-5a8cd600-d4e5-11ea-8a07-775cf3e32a2f.png"></img>
2020-04-26 06:03:17 +03:00
### MediumStruct
2020-08-02 11:27:38 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118974-5d87c680-d4e5-11ea-8f4e-dbb01c2dd861.png"></img>
2020-04-26 06:03:17 +03:00
### LargeStruct
2020-08-02 11:27:38 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118977-5f518a00-d4e5-11ea-8bfe-1455fc71c963.png"></img>
2020-04-26 06:03:17 +03:00
2020-08-02 11:24:39 +03:00
## Decode
**So faster than json-iterator/go**
2020-04-26 06:03:17 +03:00
2020-08-02 11:27:38 +03:00
## json.Unmarshal
2020-04-26 06:03:17 +03:00
### SmallStruct
2020-08-02 11:24:39 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118870-5b713800-d4e4-11ea-9c80-47008d998e70.png"></img>
2020-04-26 06:03:17 +03:00
### MediumStruct
2020-08-02 11:24:39 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118884-86f42280-d4e4-11ea-965c-b72764870ed0.png"></img>
2020-04-26 06:03:17 +03:00
### LargeStruct
2020-08-02 11:24:39 +03:00
<img src="https://user-images.githubusercontent.com/209884/89118902-9c694c80-d4e4-11ea-94e6-8c888cdb6361.png"></img>
2020-08-02 11:27:38 +03:00
## Stream Decode
### SmallStruct
<img src="https://user-images.githubusercontent.com/209884/89118906-b0ad4980-d4e4-11ea-80fb-2a6e9e7a066e.png"></img>
### MediumStruct
<img src="https://user-images.githubusercontent.com/209884/89118917-c02c9280-d4e4-11ea-8ba8-776cdbf970df.png"></img>
### LargeStruct
<img src="https://user-images.githubusercontent.com/209884/89118920-c28eec80-d4e4-11ea-91cc-424cfe726539.png"></img>
2020-08-02 11:38:04 +03:00
# Status
## Type
Currently supported all types
## API
- [ ] `Compact`
- [ ] `HTMLEscape`
- [ ] `Indent`
- [x] `Marshal`
- [x] `MarshalIndent`
- [x] `Unmarshal`
- [ ] `Valid`
- [x] `NewDecoder`
- [x] `(*Decoder).Buffered`
- [x] `(*Decoder).Decode`
- [ ] `(*Decoder).DisallowUnknownFields`
- [x] `(*Decoder).InputOffset`
- [x] `(*Decoder).More`
- [x] `(*Decoder).Token`
- [ ] `(*Decoder).UseNumber`
- [x] `Delim`
- [x] `(Delim).String`
- [x] `NewEncoder`
- [x] `(*Encoder).Encode`
- [x] `(*Encoder).SetEscapeHTML`
- [x] `(*Encoder).SetIndent`
### Error
- [ ] `InvalidUTF8Error`
- [x] `InvalidUnmarshalError`
- [x] `MarshalerError`
- [x] `SyntaxError`
- [ ] `UnmarshalFieldError`
- [ ] `UnmarshalTypeError`
- [x] `UnsupportedTypeError`
- [x] `UnsupportedValueError`
2020-04-22 07:06:52 +03:00
# License
MIT