Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
f5958c61
Commit
f5958c61
authored
Jan 17, 2013
by
Oling Cat
Committed by
Andrew Gerrand
Jan 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/articles/json_and_go: fix some format.
R=golang-dev, adg CC=golang-dev
https://golang.org/cl/7131045
parent
44ff17e6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
doc/articles/json_and_go.html
doc/articles/json_and_go.html
+9
-8
No files found.
doc/articles/json_and_go.html
View file @
f5958c61
...
...
@@ -43,7 +43,7 @@ and an instance of <code>Message</code>
{{code "/doc/progs/json1.go" `/m :=/`}}
<p>
we can marshal a JSON-encoded version of
m
using
<code>
json.Marshal
</code>
:
we can marshal a JSON-encoded version of
<code>
m
</code>
using
<code>
json.Marshal
</code>
:
</p>
{{code "/doc/progs/json1.go" `/b, err :=/`}}
...
...
@@ -151,11 +151,11 @@ type?
<p>
<code>
Unmarshal
</code>
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
<code>
Unmarshal
</code>
.
destination type. In this case, only the
<code>
Name
</code>
field of m will be
populated, and the
<code>
Food
</code>
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
<code>
Unmarshal
</code>
.
</p>
<p>
...
...
@@ -163,7 +163,7 @@ But what if you don't know the structure of your JSON data beforehand?
</p>
<p>
<b>
Generic JSON with
interface{}
</b>
<b>
Generic JSON with
<code>
interface{}
</code>
</b>
</p>
<p>
...
...
@@ -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/`}}
<p>
The json package uses
<code>
map[string]interface{}
</code>
and
<code>
[]interface{}
</code>
values to store arbitrary JSON objects and arrays;
it will happily unmarshal any valid JSON blob into a plain
<code>
interface{}
</code>
value. The default concrete Go types are:
</p>
<ul>
<li>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment