Closed GoogleCodeExporter closed 9 years ago
I see now that that there is a "spec" keyword arg to the ub.decode() method.
Can the default behavior be a permissive parser that understands both 8 and 9
syntax when decoding?
Original comment by m...@codeforamerica.org
on 13 Jul 2013 at 9:50
Probably, it's time to set Draft-9 as default one. I just pushed this change in
ref017d0e09aa and using Draft-8 is considered deprecated. I'll take a look is
there everything is ready and make 0.7 release on head of next week. Stay
tuned! (:
> Can the default behavior be a permissive parser that understands both 8 and 9
syntax when decoding?
I prefer explicit way of such guessing, so in client code you'll have something
like:
try:
obj = simpleubjson.decode(data, spec='draft-9')
except simpleubjson.DecodeError:
obj = simpleubjson.decode(data, spec='draft-8')
or vice versa. Having same code in simpleubjson doesn't make a sense and may
hurt you performance since on spec upgrading data have to be parsed twice (and
twice it may fails for malformed data). Also this trick fails for steamed, so
you have to keep somewhere buffer to not lose already decoded data.
Original comment by kxepal
on 13 Jul 2013 at 11:48
The try/catch seems fair to me, thanks!
Original comment by m...@codeforamerica.org
on 14 Jul 2013 at 6:57
Original issue reported on code.google.com by
m...@codeforamerica.org
on 13 Jul 2013 at 9:46