Answer the question
In order to leave comments, you need to log in
How to form a structure from multilevel json in go?
tell me how to form a structure from a multi-level json on go:
That is, I'm trying to do it like this:[{ status: 200, body: { user: 'Bravis' }]
jsonResp := map[string]string {
"status" : "200",
},
body : map[string]string {
"user" : u.Value,
"hand" : "Right",
},
}
jsonResponse, _ := json.Marshal(jsonResp)
fmt.Fprintf(w, string(jsonResponse))
Answer the question
In order to leave comments, you need to log in
package main
import (
"fmt"
"encoding/json"
)
func main() {
jsonResp := map[string]interface {}{"status" : "200", "body": map[string]interface {} {"user": "s", "dd": "dd"}}
jsonResponse, _ := json.Marshal(jsonResp)
fmt.Println(string(jsonResponse))
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question