Skip to content

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

Closed
@fangguangyang

Description

@fangguangyang

_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:"-"`
        ...
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions