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
09d4bcf0
Commit
09d4bcf0
authored
Jan 12, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json: do not Marshal unexported struct fields
R=r, cw, niemeyer, rsc CC=golang-dev
https://golang.org/cl/3952041
parent
a41d8549
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
src/pkg/json/decode_test.go
src/pkg/json/decode_test.go
+2
-0
src/pkg/json/encode.go
src/pkg/json/encode.go
+9
-2
No files found.
src/pkg/json/decode_test.go
View file @
09d4bcf0
...
...
@@ -270,6 +270,8 @@ type All struct {
Interface
interface
{}
PInterface
*
interface
{}
unexported
int
}
type
Small
struct
{
...
...
src/pkg/json/encode.go
View file @
09d4bcf0
...
...
@@ -37,6 +37,7 @@ import (
// a member of the object. By default the object's key name is the
// struct field name converted to lower case. If the struct field
// has a tag, that tag will be used as the name instead.
// Only exported fields will be encoded.
//
// Map values encode as JSON objects.
// The map's key type must be string; the object keys are used directly
...
...
@@ -219,11 +220,17 @@ func (e *encodeState) reflectValue(v reflect.Value) {
e
.
WriteByte
(
'{'
)
t
:=
v
.
Type
()
.
(
*
reflect
.
StructType
)
n
:=
v
.
NumField
()
first
:=
true
for
i
:=
0
;
i
<
n
;
i
++
{
if
i
>
0
{
f
:=
t
.
Field
(
i
)
if
f
.
PkgPath
!=
""
{
continue
}
if
first
{
first
=
false
}
else
{
e
.
WriteByte
(
','
)
}
f
:=
t
.
Field
(
i
)
if
f
.
Tag
!=
""
{
e
.
string
(
f
.
Tag
)
}
else
{
...
...
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