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

结构体中下划线开头的字段 会被序列化到json #449

Closed
fangguangyang opened this issue Mar 25, 2020 · 2 comments
Closed

结构体中下划线开头的字段 会被序列化到json #449

fangguangyang opened this issue Mar 25, 2020 · 2 comments

Comments

@fangguangyang
Copy link

_msgpack会被序列化到json中, msg不会

type Live struct {
	_msgpack struct{}    `msgpack:",asArray"`
        msg      string      `json:"msg"`
	Tagname  string      `json:"tagname"`
	Value    interface{} `json:"value"`	
}

增加json:"-"可以起作用,不会被序列化到json中

type Live struct {
	_msgpack struct{}    `msgpack:",asArray" json:"-"`
        ...
}

尝试官方库下划线开头字段不会被序列化

AllenX2018 added a commit that referenced this issue Mar 26, 2020
@AllenX2018
Copy link
Collaborator

Fixed. Thanks for reporting!

@fangguangyang
Copy link
Author

it working now, Thanks

zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants