Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
simplejson
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
simplejson
Commits
1e23b865bb74
Commit
1e23b865bb74
authored
13 years ago
by
Janne Kulmala
Browse files
Options
Downloads
Patches
Plain Diff
raw_decode(): Skip whitespace before the object
parent
a0a453784523
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
simplejson/decoder.py
+3
-3
3 additions, 3 deletions
simplejson/decoder.py
with
3 additions
and
3 deletions
simplejson/decoder.py
+
3
−
3
View file @
1e23b865
...
@@ -403,9 +403,9 @@
...
@@ -403,9 +403,9 @@
instance containing a JSON document)
instance containing a JSON document)
"""
"""
obj
,
end
=
self
.
raw_decode
(
s
,
idx
=
_w
(
s
,
0
).
end
()
)
obj
,
end
=
self
.
raw_decode
(
s
)
end
=
_w
(
s
,
end
).
end
()
end
=
_w
(
s
,
end
).
end
()
if
end
!=
len
(
s
):
if
end
!=
len
(
s
):
raise
JSONDecodeError
(
"
Extra data
"
,
s
,
end
,
len
(
s
))
raise
JSONDecodeError
(
"
Extra data
"
,
s
,
end
,
len
(
s
))
return
obj
return
obj
...
@@ -407,9 +407,9 @@
...
@@ -407,9 +407,9 @@
end
=
_w
(
s
,
end
).
end
()
end
=
_w
(
s
,
end
).
end
()
if
end
!=
len
(
s
):
if
end
!=
len
(
s
):
raise
JSONDecodeError
(
"
Extra data
"
,
s
,
end
,
len
(
s
))
raise
JSONDecodeError
(
"
Extra data
"
,
s
,
end
,
len
(
s
))
return
obj
return
obj
def
raw_decode
(
self
,
s
,
idx
=
0
):
def
raw_decode
(
self
,
s
,
idx
=
0
,
_w
=
WHITESPACE
.
match
):
"""
Decode a JSON document from ``s`` (a ``str`` or ``unicode``
"""
Decode a JSON document from ``s`` (a ``str`` or ``unicode``
beginning with a JSON document) and return a 2-tuple of the Python
beginning with a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
representation and the index in ``s`` where the document ended.
...
@@ -421,7 +421,7 @@
...
@@ -421,7 +421,7 @@
"""
"""
try
:
try
:
obj
,
end
=
self
.
scan_once
(
s
,
idx
)
obj
,
end
=
self
.
scan_once
(
s
,
idx
=
_w
(
s
,
idx
).
end
()
)
except
StopIteration
:
except
StopIteration
:
raise
JSONDecodeError
(
"
No JSON object could be decoded
"
,
s
,
idx
)
raise
JSONDecodeError
(
"
No JSON object could be decoded
"
,
s
,
idx
)
return
obj
,
end
return
obj
,
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment