kahntang / as3corelib

Automatically exported from code.google.com/p/as3corelib
0 stars 0 forks source link

JSON cannot decode Infinity or -Infinity #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
<b>What steps will reproduce the problem?</b>

<i>1.</i> trace(JSON.decode(Infinity));   <i>or</i>
<i>2.</i> trace(JSON.decode(-Infinity));

<b>What is the expected output? What do you see instead?</b>

<i>Expected output would be the same as the input:</i> Infinity <i>or</i>
-Infinity.

<i>Infinity error:</i>

Error: Unexpected I encountered
    at com.adobe.serialization.json::JSONTokenizer/parseError()
    at com.adobe.serialization.json::JSONTokenizer/getNextToken()
    at com.adobe.serialization.json::JSONDecoder/::nextToken()
    at com.adobe.serialization.json::JSONDecoder$iinit()
    at com.adobe.serialization.json::JSON$/decode()
    at json_test_fla::MainTimeline/json_test_fla::frame1()

<i>-Infinity error:</i>

Error: Expecting a digit
    at com.adobe.serialization.json::JSONTokenizer/parseError()
    at com.adobe.serialization.json::JSONTokenizer/::readNumber()
    at com.adobe.serialization.json::JSONTokenizer/getNextToken()
    at com.adobe.serialization.json::JSONDecoder/::nextToken()
    at com.adobe.serialization.json::JSONDecoder$iinit()
    at com.adobe.serialization.json::JSON$/decode()
    at json_test_fla::MainTimeline/json_test_fla::frame1()

<b>What version of the product are you using? On what operating system?</b>

<i>Latest download. Windows XP, Flash CS3.</i>

Original issue reported on code.google.com by joe.nash...@gmail.com on 17 Aug 2007 at 12:06

GoogleCodeExporter commented 9 years ago
This is not a bug.

Infinity is not supported by JSON.

See section 2.4 of the RFC

http://tools.ietf.org/html/rfc4627

Original comment by mikechambers on 2 Jul 2008 at 4:30

GoogleCodeExporter commented 9 years ago
I don't see any reason why the JSON package couldn't support Infinity though. I 
had
to add Infinity and -Infinity for a project which was sending me data over a
webservice in JSON format. I had to build it in - so why can it not be built in 
by
default? My JSON Class is now more fully featured as a result.

Original comment by joe.nash...@gmail.com on 2 Jul 2008 at 8:03