Skip to content

Commit

Permalink
check for dupe keys
Browse files Browse the repository at this point in the history
git-svn-id: http://simplejson.googlecode.com/svn/trunk@24 a4795897-2c25-0410-b006-0d3caba88fa1
  • Loading branch information
etrepum committed Apr 27, 2006
1 parent bb0890c commit 423da8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions simplejson/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def JSONObject(match, context, _w=WHITESPACE.match):
value, end = iterscan(s, idx=end, context=context).next()
except StopIteration:
raise ValueError(errmsg("Expecting object", s, end))
if key in pairs:
raise ValueError(errmsg("Duplicate property name", s, end))
pairs[key] = value
end = _w(s, end).end()
nextchar = s[end:end + 1]
Expand Down
2 changes: 2 additions & 0 deletions simplejson/tests/test_fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
'["Bad value", truth]',
# http://json.org/JSON_checker/test/fail24.json
"['single quote']",
# Not part of the JSON spec
'{"a": 1, "a": 1}',
]

SKIPS = {
Expand Down

0 comments on commit 423da8c

Please sign in to comment.