How to go to form the structure of multi-level json?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
13 views
how to go to form a multi-level structure of the json:
[{ status: 200, body: { user: 'Bravis' }]

That is, trying to do so:
jsonResp := map[string]string { "status" : "200", }, body : map[string]string { "user" : u.Value "hand" : "Right", }, } jsonResponse, _ := json.Marshal(jsonResp) fmt.Fprintf(w, string(jsonResponse))


But this trick does not work
by | 13 views

1 Answer

0 like 0 dislike
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)) }


https://play.golang.org/p/OWCjJfxPBao

But it is better to use structure
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jun 10, 2019 by starosta46
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
asked Apr 9, 2019 by Pavel_Timofeev
110,608 questions
257,186 answers
0 comments
35,456 users