Skip to content

Commit 463e1c0

Browse files
authored
Update go-tips.md
1 parent b700ae6 commit 463e1c0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

go-tips.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ decoder1.Decode(&obj1)
256256
should.Equal(json.Number("123"), obj1)
257257
```
258258

259-
jsoniter 支持标准库的这个用法。同时,扩展了行为使得 Unmarshal 也可以支持 UseNumber 了。
259+
jsoniter support this usage. And it extended the support to `Unmarshal` as will.
260260

261261
```golang
262262
json := Config{UseNumber:true}.Froze()
@@ -265,9 +265,9 @@ json.UnmarshalFromString("123", &obj)
265265
should.Equal(json.Number("123"), obj)
266266
```
267267

268-
# 统一更改字段的命名风格
268+
# Field naming strategy
269269

270-
经常 JSON 里的字段名 Go 里的字段名是不一样的。我们可以用 field tag 来修改。
270+
Most of the time, we want to different field names in JSON. We can use field tag:
271271

272272
```golang
273273
output, err := jsoniter.Marshal(struct {
@@ -280,7 +280,7 @@ output, err := jsoniter.Marshal(struct {
280280
should.Equal(`{"user_name":"taowen","first_language":"Chinese"}`, string(output))
281281
```
282282

283-
但是一个个字段来设置,太麻烦了。如果使用 jsoniter,我们可以统一设置命名风格。
283+
However, it is tedious. If you are using jsoniter, we can change all fields in one line.
284284

285285
```golang
286286
import "github.com/json-iterator/go/extra"
@@ -297,9 +297,9 @@ should.Nil(err)
297297
should.Equal(`{"user_name":"taowen","first_language":"Chinese"}`, string(output))
298298
```
299299

300-
# 使用私有的字段
300+
# Private fields
301301

302-
Go 的标准库只支持 public 的 field。jsoniter 额外支持了 private 的 field。需要使用 `SupportPrivateFields()` 来开启开关。
302+
The standard library requries all fields appear in JSON to be public. If you use jsoniter, `SupportPrivateFields()` will remove this restriction.
303303

304304
```golang
305305
import "github.com/json-iterator/go/extra"

0 commit comments

Comments
 (0)