Open
Description
In JSON either action is valid for duplicate keys. Currently we process every duplicate key with a potential performance penalty. A better alternative would be to generate code like:
var
onceBanana = false
eat(p, tkCurlyLe)
while p.tok != tkCurlyRi:
if p.tok != tkString:
raiseParseErr(p, "string literal as key")
case p.a
of "banana":
discard getTok(p)
eat(p, tkColon)
if not onceBanana:
onceBanana = true
initFromJson(dst.banana, p)
else:
when defined(emiDuplicateKey):
skipJson(p)
else: raiseParseErr(p, "duplicate object field")
else:
raiseParseErr(p, "valid object field")
if p.tok != tkComma:
break
discard getTok(p)
eat(p, tkCurlyRi)
...and leave it up to the user to specify whether it should error or skip them.
Metadata
Metadata
Assignees
Labels
No labels