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:

'[1e9999,-1e9999,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 
<alexander.m.bee...@gmail.com> wrote:
>Test-case / repro:
>“SELECT JSON_ARRAY(1e9999,-1e9999,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

Reply via email to