开发者

How to define a json struct type for function signature?

开发者 https://www.devze.com 2022-12-07 19:53 出处:网络
I have a struct definition type ds struct { namestring TagList[]struct { Keystring `json:"Key"`

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

精彩评论

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