Skip to content

Commit 8286705

Browse files
committed
Revert "refactor(json): make jsonite optional with build tags (gin-gonic#1026)"
This reverts commit ce670a6.
1 parent 89bebbb commit 8286705

File tree

7 files changed

+9
-47
lines changed

7 files changed

+9
-47
lines changed

README.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ BenchmarkZeus_GithubAll | 2000 | 944234 | 300688 | 2648
8888
- [x] Battle tested
8989
- [x] API frozen, new releases will not break your code.
9090

91+
9192
## Start using it
9293

9394
1. Download and install it:
@@ -140,14 +141,6 @@ $ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/mai
140141
$ go run main.go
141142
```
142143

143-
## Build with [jsoniter](https://github.com/json-iterator/go)
144-
145-
Gin use `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags.
146-
147-
```sh
148-
$ go build -tags=jsoniter .
149-
```
150-
151144
## API Examples
152145

153146
### Using GET, POST, PUT, PATCH, DELETE and OPTIONS

binding/json.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ package binding
77
import (
88
"net/http"
99

10-
"github.com/gin-gonic/gin/json"
10+
"github.com/json-iterator/go"
1111
)
1212

1313
var (
14+
json = jsoniter.ConfigCompatibleWithStandardLibrary
1415
EnableDecoderUseNumber = false
1516
)
1617

errors.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import (
99
"fmt"
1010
"reflect"
1111

12-
"github.com/gin-gonic/gin/json"
12+
"github.com/json-iterator/go"
1313
)
1414

15+
var json = jsoniter.ConfigCompatibleWithStandardLibrary
16+
1517
type ErrorType uint64
1618

1719
const (

errors_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"testing"
1010

11-
"github.com/gin-gonic/gin/json"
1211
"github.com/stretchr/testify/assert"
1312
)
1413

json/json.go

-17
This file was deleted.

json/jsoniter.go

-18
This file was deleted.

render/json.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import (
88
"bytes"
99
"net/http"
1010

11-
"github.com/gin-gonic/gin/json"
11+
"github.com/json-iterator/go"
1212
)
1313

14+
var json = jsoniter.ConfigCompatibleWithStandardLibrary
15+
1416
type JSON struct {
1517
Data interface{}
1618
}

0 commit comments

Comments
 (0)