开发者

How to define a json struct type for function signature?

I have a struct definition

type ds struct {
    name     string
    TagList                          []struct {
        Key   string `json:"Key"`
        Value string `json:"Value"`
    } `json:"TagList"`
}

I want to have a function that converts the TagList into string arrays (my own serialization function). So the function will look like this

func serialize(tagList开发者_JS百科 <?>) string

What I should define as the type <?> is what I am not sure about. Because if I called this function using

serialize(mydata.TagList)  // mydata is the ds struct type

Then it will remind me that this type is []struct{...}

But I am not sure how to define the []struct{...}.

I am also open for existing serialization library apis i can use to do this as long as it serialized into a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜