diff options
Diffstat (limited to 'src/encoding/json/example_test.go')
| -rw-r--r-- | src/encoding/json/example_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/encoding/json/example_test.go b/src/encoding/json/example_test.go index 2bbc292c6d..39b3231850 100644 --- a/src/encoding/json/example_test.go +++ b/src/encoding/json/example_test.go @@ -273,3 +273,22 @@ func ExampleIndent() { // = } // =] } + +func ExampleMarshalIndent() { + data := map[string]int{ + "a": 1, + "b": 2, + } + + json, err := json.MarshalIndent(data, "<prefix>", "<indent>") + if err != nil { + log.Fatal(err) + } + + fmt.Println(string(json)) + // Output: + // { + // <prefix><indent>"a": 1, + // <prefix><indent>"b": 2 + // <prefix>} +} |
