Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
68d3b6e5
Commit
68d3b6e5
authored
Nov 30, 2009
by
Andrew Skiba
Committed by
Russ Cox
Nov 30, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle \r as a whitespace when parsing JSON string.
Fixes #272. R=rsc
https://golang.org/cl/161061
parent
c78710f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
parse.go
src/pkg/json/parse.go
+1
-1
struct_test.go
src/pkg/json/struct_test.go
+11
-0
No files found.
src/pkg/json/parse.go
View file @
68d3b6e5
...
...
@@ -198,7 +198,7 @@ func punct(c byte) bool {
return
c
==
'"'
||
c
==
'['
||
c
==
']'
||
c
==
':'
||
c
==
'{'
||
c
==
'}'
||
c
==
','
}
func
white
(
c
byte
)
bool
{
return
c
==
' '
||
c
==
'\t'
||
c
==
'\n'
||
c
==
'\v'
}
func
white
(
c
byte
)
bool
{
return
c
==
' '
||
c
==
'\t'
||
c
==
'\
r'
||
c
==
'\
n'
||
c
==
'\v'
}
func
skipwhite
(
p
string
,
i
int
)
int
{
for
i
<
len
(
p
)
&&
white
(
p
[
i
])
{
...
...
src/pkg/json/struct_test.go
View file @
68d3b6e5
...
...
@@ -66,6 +66,17 @@ func check(t *testing.T, ok bool, name string, v interface{}) {
}
}
const
whiteSpaceEncoded
=
"
\t
{
\n\"
s
\"\r
:
\"
string
\"\v
}"
func
TestUnmarshalWhitespace
(
t
*
testing
.
T
)
{
var
m
myStruct
;
ok
,
errtok
:=
Unmarshal
(
whiteSpaceEncoded
,
&
m
);
if
!
ok
{
t
.
Fatalf
(
"Unmarshal failed near %s"
,
errtok
)
}
check
(
t
,
m
.
S
==
"string"
,
"string"
,
m
.
S
);
}
func
TestUnmarshal
(
t
*
testing
.
T
)
{
var
m
myStruct
;
m
.
F
=
true
;
...
...
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