Add support go-json, another drop-in json replacement. (#2680)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by zzjin · committed by GitHub · parent f1da692 · Browse files · 4 files·+36 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Co-authored-by: thinkerou <thinkerou@gmail.com>
Diff stats
4 files+36 added−5 removed
- other:+36 added−5 removed
Provenance
- Commit
c0418c4- Tree
5b2f3e6- Author
zzjin <zzjin@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
f1da692
4 files changed+36 added−5 removed
added:internal/json/go_json.go+23 added
1+// Copyright 2017 Bo-Yi Wu. All rights reserved.2+// Use of this source code is governed by a MIT style3+// license that can be found in the LICENSE file.4+5+//go:build go_json6+// +build go_json7+8+package json9+10+import json "github.com/goccy/go-json"11+12+var (13+ // Marshal is exported by gin/json package.14+ Marshal = json.Marshal15+ // Unmarshal is exported by gin/json package.16+ Unmarshal = json.Unmarshal17+ // MarshalIndent is exported by gin/json package.18+ MarshalIndent = json.MarshalIndent19+ // NewDecoder is exported by gin/json package.20+ NewDecoder = json.NewDecoder21+ // NewEncoder is exported by gin/json package.22+ NewEncoder = json.NewEncoder23+)modified:internal/json/json.go+2 added-2 removed
1 // Copyright 2017 Bo-Yi Wu. All rights reserved.2 // Use of this source code is governed by a MIT style3 // license that can be found in the LICENSE file.4 5-//go:build !jsoniter6-// +build !jsoniter5+//go:build !jsoniter && !go_json6+// +build !jsoniter,!go_json7 8 package json9 10 import "encoding/json"13 unmodified linesmodified:go.sum+2 added
9 unmodified lines10 github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=11 github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=12 github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=13 github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=14+github.com/goccy/go-json v0.4.11 h1:92nyX606ZN/cUFwctfxwDWm8YWSA38Zlv9s7taFeLyo=15+github.com/goccy/go-json v0.4.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=16 github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=17 github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=18 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=19 github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=35 unmodified linesmodified:README.md+9 added-3 removed
21 unmodified lines22 - [Installation](#installation)23 - [Quick start](#quick-start)24 - [Benchmarks](#benchmarks)25 - [Gin v1. stable](#gin-v1-stable)26- - [Build with jsoniter](#build-with-jsoniter)26+ - [Build with jsoniter/go-json](#build-with-json-replacement)27 - [API Examples](#api-examples)28 - [Using GET, POST, PUT, PATCH, DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options)29 - [Parameters in path](#parameters-in-path)30 - [Querystring parameters](#querystring-parameters)150 unmodified lines181 - [x] Complete suite of unit tests.182 - [x] Battle tested.183 - [x] API frozen, new releases will not break your code.184 185-## Build with [jsoniter](https://github.com/json-iterator/go)185+## Build with json replacement186 187-Gin uses `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags.187+Gin uses `encoding/json` as default json package but you can change it by build from other tags.188 189+[jsoniter](https://github.com/json-iterator/go)190 ```sh191 $ go build -tags=jsoniter .192 ```193+[go-json](https://github.com/goccy/go-json)194+```sh195+$ go build -tags=go_json .196+```197 198 ## API Examples199 200 You can find a number of ready-to-run examples at [Gin examples repository](https://github.com/gin-gonic/examples).2018 unmodified lines2219 * [krakend](https://github.com/devopsfaith/krakend): Ultra performant API Gateway with middlewares.2220 * [picfit](https://github.com/thoas/picfit): An image resizing server written in Go.2221 * [brigade](https://github.com/brigadecore/brigade): Event-based Scripting for Kubernetes.2222 * [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system.2223+