Hello All,
I have a struct
type Response struct {
Status string json:"status"
Message string json:"message"
}
i have strings
stat := “Valid”
msg := fmt.Sprinf(abc"+" cde)
i want this stat and msg to be passed to the struct Response and use it in json encoding how can i achieve it
Just create a var of type Reponse and assign each property its corresponding value.
stat := “Valid”
msg := fmt.Sprinf(abc"+" cde)
newResponse := Response{ Status:stat, Message:msg}
b, err := json.Marshal(newResponse)
system
(system)
Closed
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.