Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: move json_marshal to basic_feature #748

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
title: "JSON Marshal Library"
linkTitle: "JSON Marshal Library"
weight: 3
date: 2023-08-03
weight: 19
description: >

---

By default, Hertz integrates with and uses [Sonic](https://github.com/bytedance/sonic) for serializing `ctx.JSON` interface and deserialization requests as defined in the `binding` package.
Sonic is an ultra-high performance golang json library, also see Sonic [README](https://github.com/bytedance/sonic) for details.

The following are requirements to enable Sonic:

- Go 1.15/1.16/1.17/1.18
- Go 1.16 or above
- Linux / darwin OS / Windows
- Amd64 CPU with AVX instruction set

Expand Down Expand Up @@ -69,7 +69,7 @@ go build -tags stdjson .

Usually because the Go version or environment parameters do not meet Sonic requirements.

- Go version: go1.15 or above, recommend go1.17 or above. For the currently supported versions of Sonic, please see [Sonic#Requirement](https://github.com/bytedance/sonic#requirement)
- Go version: go1.16 or above, recommend go1.17 or above. For the currently supported versions of Sonic, please see [Sonic#Requirement](https://github.com/bytedance/sonic#requirement).

- Go environment parameters: set GOARCH=**amd64**. Because Sonic already supports the binary translation software Rosetta, with Rosetta, the programs compiled under the x86 environment can be run on the M1.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---
title: "JSON Marshal 库"
linkTitle: "JSON Marshal 库"
weight: 3
date: 2023-08-03
weight: 19
description: >

---


Hertz 默认集成并使用 [Sonic](https://github.com/bytedance/sonic) 用于序列化`ctx.JSON`接口,以及反序列化`binding`包中的请求。Sonic 是一款超高性能 golang json 库,详情参考 Sonic [README](https://github.com/bytedance/sonic) 。

开启 Sonic 需要满足以下条件:

- Go 1.15/1.16/1.17/1.18
- Go 1.16 以上
- Linux / darwin OS / Windows
- Amd64 CPU with AVX instruction set

Expand Down Expand Up @@ -45,8 +44,8 @@ import (

)
func main() {
// Render
render.ResetJSONMarshal(json.Marshal)
// Render
li-jin-gou marked this conversation as resolved.
Show resolved Hide resolved
render.ResetJSONMarshal(json.Marshal)

// Binding
binding.ResetJSONUnmarshaler(json.Unmarshal)
Expand All @@ -67,9 +66,9 @@ go build -tags stdjson .

#### Build constraints exclude all Go files in xxx

一般为是因为 Go 镜像版本或环境参数不符合 Sonic 要求。
li-jin-gou marked this conversation as resolved.
Show resolved Hide resolved
一般是因为 Go 镜像版本或环境参数不符合 Sonic 要求。

- Go 版本:go1.15 或以上,推荐 go1.17 以上版本。Sonic 目前支持的版本见 [Sonic#Requirement](https://github.com/bytedance/sonic#requirement)
- Go 版本:go1.16 或以上,推荐 go1.17 以上版本。Sonic 目前支持的版本见 [Sonic#Requirement](https://github.com/bytedance/sonic#requirement)

- Go 环境参数:设置 GOARCH=**amd64**。因为,Sonic 已经支持二进制翻译软件 Rosetta,借助 Rosetta,在 M1 上可运行 x86 环境下编译出来的程序。

Expand Down
Loading