docs(py2go): fix JSON struct tag examples in module 4 - #51
Open
tech-fever wants to merge 1 commit into
Open
Conversation
- Remove invalid `json:"internal,internal"` option (internal is not supported; unknown options are silently ignored) - Document the four encoding/json tag options: omitempty, string, omitzero, "-" - Fix duplicate JSON key collision between Name and DBName fields (DBName json tag changed to "db_name") - Apply consistently across en, zh-cn, zh-tw
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fix invalid
json:"internal,internal"option, document the four encoding/json tag options (omitempty, string, omitzero, -), and fix the duplicate JSON key collision between Name and DBName across en/zh-cn/zh-tw.概述
修复 py2go 第 4 模块(Structs and Interfaces)结构体标签示例中的两处问题。
改动
移除无效的
json:"internal,internal"选项encoding/json并不支持internal这个选项,未知选项会被静默忽略。已改为合法的
json:"internal,omitempty"。并且示例中 Internal 留空来示范 omitempty 的作用。补充
encoding/json支持的四个选项说明omitempty、string、omitzero(Go 1.24+)、-,帮助读者理解正确的标签写法。修复
Name与DBName的 JSON 键冲突DBName原使用json:"name",会与Name字段产生重复键,序列化输出会有歧义,已改为json:"db_name"。范围
同步更新了英文、简体中文、繁体中文三个版本。