From f5958c614166e957f2e409aaaf1db30e3c17e794 Mon Sep 17 00:00:00 2001 From: Oling Cat Date: Thu, 17 Jan 2013 15:08:20 +1100 Subject: [PATCH] doc/articles/json_and_go: fix some format. R=golang-dev, adg CC=golang-dev https://golang.org/cl/7131045 --- doc/articles/json_and_go.html | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/articles/json_and_go.html b/doc/articles/json_and_go.html index aab800e8606..8c4ef33a417 100644 --- a/doc/articles/json_and_go.html +++ b/doc/articles/json_and_go.html @@ -43,7 +43,7 @@ and an instance of Message {{code "/doc/progs/json1.go" `/m :=/`}}

-we can marshal a JSON-encoded version of m using json.Marshal: +we can marshal a JSON-encoded version of m using json.Marshal:

{{code "/doc/progs/json1.go" `/b, err :=/`}} @@ -151,11 +151,11 @@ type?

Unmarshal will decode only the fields that it can find in the -destination type. In this case, only the Name field of m will be populated, -and the Food field will be ignored. This behavior is particularly useful when -you wish to pick only a few specific fields out of a large JSON blob. It also -means that any unexported fields in the destination struct will be unaffected -by Unmarshal. +destination type. In this case, only the Name field of m will be +populated, and the Food field will be ignored. This behavior is +particularly useful when you wish to pick only a few specific fields out of a +large JSON blob. It also means that any unexported fields in the destination +struct will be unaffected by Unmarshal.

@@ -163,7 +163,7 @@ But what if you don't know the structure of your JSON data beforehand?

-Generic JSON with interface{} +Generic JSON with interface{}

@@ -190,11 +190,12 @@ Or, if the underlying type is unknown, a type switch determines the type: {{code "/doc/progs/json2.go" `/switch v/` `/STOP/`}} - +

The json package uses map[string]interface{} and []interface{} values to store arbitrary JSON objects and arrays; it will happily unmarshal any valid JSON blob into a plain interface{} value. The default concrete Go types are: +