On Sun, Apr 9, 2017 at 10:34 AM, Olivier Mascia <[email protected]> wrote:
> > Le 9 avr. 2017 à 03:08, Jens Alfke <[email protected]> a écrit : > > > >> On Apr 7, 2017, at 5:26 PM, Rolf Ade <[email protected]> wrote: > >> ./sqlite3 > >> SQLite version 3.19.0 2017-04-07 20:20:08 > >> [...] > >> sqlite> select json(' { "this" : 000.23 } '); > >> {"this":000.23} > >> If I read RFC 7159 (http://www.rfc-editor.org/rfc/rfc7159.txt < > http://www.rfc-editor.org/rfc/rfc7159.txt>) correct > >> this should return: "Error: malformed JSON". > > > > In this case I would go with Postel’s Law, paraphrased as “Be strict in > what you write, but lenient in what you read.” I don’t see a point in > disallowing something as trivial as redundant leading zeroes. > > If you'd go with Postal's Law, you would make it so: > > sqlite> select json(' { "this" : 000.23 } '); // be lenient in what you > read > {"this":0.23} // be strict in what you > write > I disagree. There's a spec. it should be followed, by default. A separate, explicitly enabled "lenient mode" could be added, for leading zeros, NaNs, C-comments, binary strings, etc... but it should not be the default. Otherwise you end up forever having to support non-conformity, possibly simply because of an oversights. Plus json_valid() is then lying about checking well-formed'ness. --DD sqlite> select json_valid(''); 0 sqlite> select json_valid('00.1'); 1 sqlite> select json_valid('0.1'); 1 sqlite> select json_valid('[]'); 1 sqlite> select json_valid('[00]'); 1 sqlite> select json_valid('[00.00]'); 1 sqlite> _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

