[[Go]]で[[JSON]]文字列(string)をインデントをつけて見やすく出力したい場合。`json.MarshalIndent`を使う。 ```go package main import ( "encoding/json" "fmt" ) type human struct { Id int Name string } func main() { me := human{ Id: 123, Name: "mimizou", } r, _ := json.MarshalIndent(me, "", " ") fmt.Println(string(r)) } ``` ```json { "Id": 123, "Name": "mimizou" } ``` <button class="playground"><a href="https://go.dev/play/p/ot-vuK0rHNo">Playground</a></button>