Re: [sqlite] Minor JSON output bug (infinity)
On Mon, Jan 22, 2018 at 6:00 PM, Alexander Beedie < alexander.m.bee...@gmail.com> wrote: > Test-case / repro: > “SELECT JSON_ARRAY(1e,-1e,NULL)” > > Actual output: > ‘[Inf,-Inf,null]’ > > Expected output: > ‘[Infinity,-Infinity,null]’ > > All JSON parsers I have tried fail on “Inf”, but the majority will succeed > with “Infinity” (as this is the standard JS property name) > JSON5 or JSON6 handle it. http://json5.org/ https://github.com/d3x0r/json6 ( https://github.com/d3x0r/SACK/blob/master/src/netlib/html5.websocket/json/json6_parser.c ) (also NaN) but yes that is a deficiency in JSON. > eg: in standard python - > > >> import json > >> json.loads( ‘[Inf,-Inf,null]’ ) > ValueError: No JSON object could be decoded > >> json.loads( ‘[Infinity,-Infinity,null]’ ) > [inf, -inf, None] > > > Regards, > > -Alex > -- > iPhoneから送信 > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Minor JSON output bug (infinity)
RFC 8259 states: > Numeric values that cannot be represented in the grammar below (such as > Infinity and NaN) are not permitted. This is one of the cases that expose the fallacy of the "JS" part of "JSON". While SQLite should not be producing Inf as a bare word, it should not be producing Infinity, either, as a conforming parser would reject both. What to do in such a case is undefined, but for the stated case there is actually a very sensible conforming output: '[1e,-1e,null]' I realize it is impractical for SQLite to do so, but given that JSON numbers convey arbitrary precision, only explicit infinity should, ideally, result in undefined behaviour. On January 22, 2018 9:00:35 PM EST, Alexander Beedie wrote: >Test-case / repro: >“SELECT JSON_ARRAY(1e,-1e,NULL)” > >Actual output: >‘[Inf,-Inf,null]’ > >Expected output: >‘[Infinity,-Infinity,null]’ > >All JSON parsers I have tried fail on “Inf”, but the majority will >succeed with “Infinity” (as this is the standard JS property name) > >eg: in standard python - > >>> import json >>> json.loads( ‘[Inf,-Inf,null]’ ) >ValueError: No JSON object could be decoded >>> json.loads( ‘[Infinity,-Infinity,null]’ ) >[inf, -inf, None] > > >Regards, > >-Alex >-- >iPhoneから送信 >___ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Minor JSON output bug (infinity)
On 1/22/18, Alexander Beedie wrote: > Test-case / repro: > “SELECT JSON_ARRAY(1e,-1e,NULL)” > > Actual output: > ‘[Inf,-Inf,null]’ > > Expected output: > ‘[Infinity,-Infinity,null]’ > > All JSON parsers I have tried fail on “Inf”, but the majority will succeed > with “Infinity” (as this is the standard JS property name) A strict reading of https://json.org/ suggests that neither "Inf" nor "Infinity" ought to work. I'm not sure how we ought to deal with this > > eg: in standard python - > >>> import json >>> json.loads( ‘[Inf,-Inf,null]’ ) > ValueError: No JSON object could be decoded >>> json.loads( ‘[Infinity,-Infinity,null]’ ) > [inf, -inf, None] > > > Regards, > > -Alex > -- > iPhoneから送信 > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Minor JSON output bug (infinity)
Test-case / repro: “SELECT JSON_ARRAY(1e,-1e,NULL)” Actual output: ‘[Inf,-Inf,null]’ Expected output: ‘[Infinity,-Infinity,null]’ All JSON parsers I have tried fail on “Inf”, but the majority will succeed with “Infinity” (as this is the standard JS property name) eg: in standard python - >> import json >> json.loads( ‘[Inf,-Inf,null]’ ) ValueError: No JSON object could be decoded >> json.loads( ‘[Infinity,-Infinity,null]’ ) [inf, -inf, None] Regards, -Alex -- iPhoneから送信 ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users