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
2db4c3d7
Commit
2db4c3d7
authored
Aug 03, 2010
by
Anthony Martin
Committed by
Russ Cox
Aug 03, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json: object members must have a value
R=rsc CC=golang-dev
https://golang.org/cl/1847050
parent
3ab7830d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
src/pkg/json/decode_test.go
src/pkg/json/decode_test.go
+9
-1
src/pkg/json/scanner.go
src/pkg/json/scanner.go
+2
-4
No files found.
src/pkg/json/decode_test.go
View file @
2db4c3d7
...
...
@@ -37,6 +37,9 @@ var unmarshalTests = []unmarshalTest{
unmarshalTest
{
"null"
,
new
(
interface
{}),
nil
,
nil
},
unmarshalTest
{
`{"X": [1,2,3], "Y": 4}`
,
new
(
T
),
T
{
Y
:
4
},
&
UnmarshalTypeError
{
"array"
,
reflect
.
Typeof
(
""
)}},
// syntax errors
unmarshalTest
{
`{"X": "foo", "Y"}`
,
nil
,
nil
,
SyntaxError
(
"invalid character '}' after object key"
)},
// composite tests
unmarshalTest
{
allValueIndent
,
new
(
All
),
allValue
,
nil
},
unmarshalTest
{
allValueCompact
,
new
(
All
),
allValue
,
nil
},
...
...
@@ -75,9 +78,14 @@ func TestUnmarshal(t *testing.T) {
for
i
,
tt
:=
range
unmarshalTests
{
in
:=
[]
byte
(
tt
.
in
)
if
err
:=
checkValid
(
in
,
&
scan
);
err
!=
nil
{
if
!
reflect
.
DeepEqual
(
err
,
tt
.
err
)
{
t
.
Errorf
(
"#%d: checkValid: %v"
,
i
,
err
)
continue
}
}
if
tt
.
ptr
==
nil
{
continue
}
// v = new(right-type)
v
:=
reflect
.
NewValue
(
tt
.
ptr
)
.
(
*
reflect
.
PtrValue
)
v
.
PointTo
(
reflect
.
MakeZero
(
v
.
Type
()
.
(
*
reflect
.
PtrType
)
.
Elem
()))
...
...
src/pkg/json/scanner.go
View file @
2db4c3d7
...
...
@@ -251,6 +251,8 @@ func stateBeginStringOrEmpty(s *scanner, c int) int {
return
scanSkipSpace
}
if
c
==
'}'
{
n
:=
len
(
s
.
parseState
)
s
.
parseState
[
n
-
1
]
=
parseObjectValue
return
stateEndValue
(
s
,
c
)
}
return
stateBeginString
(
s
,
c
)
...
...
@@ -289,10 +291,6 @@ func stateEndValue(s *scanner, c int) int {
s
.
step
=
stateBeginValue
return
scanObjectKey
}
if
c
==
'}'
{
s
.
popParseState
()
return
scanEndObject
}
return
s
.
error
(
c
,
"after object key"
)
case
parseObjectValue
:
if
c
==
','
{
...
...
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