diff options
| author | tbunyk <tbunyk@gmail.com> | 2017-09-05 19:01:16 +0300 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-09-12 18:12:24 +0000 |
| commit | b86fae041baff7a7077c67060bc4282d78a2118b (patch) | |
| tree | 422b34aa8cbf67be5c17ff045cbbdb5bd5c12340 /src/encoding/json/example_test.go | |
| parent | 80b2ae5878c7b08b605128cc885305bf86bc5475 (diff) | |
| download | go-b86fae041baff7a7077c67060bc4282d78a2118b.tar.xz | |
encoding/json: update documentation for MarshalIndent
Make arguments semantics clear without the need to look for
json.Indent documentation.
Change-Id: If9adfe9f477a30d426ae83790b0f2578c0a809b7
Reviewed-on: https://go-review.googlesource.com/61670
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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>} +} |
