paulbartrum / jurassic

A .NET library to parse and execute JavaScript code.
MIT License
868 stars 121 forks source link

JSONObject.Parse() fails when number is in scientific notation #208

Closed immitev closed 2 years ago

immitev commented 2 years ago

The code JSONObject.Parse(new ScriptEngine(), @" {""E-notation"":-7E-05} "); fails with "Invalid number." exception

   at Jurassic.Library.JSONLexer.ReadNumericLiteral(Int32 firstChar)
   at Jurassic.Library.JSONParser.Consume()
   at Jurassic.Library.JSONParser.ParseObjectLiteral()
   at Jurassic.Library.JSONParser.ParseValue()
   at Jurassic.Library.JSONParser.Parse()
paulbartrum commented 2 years ago

Funny, that check for leading zeros in the exponent was put in very purposely, with unit tests and everything. No idea what I was thinking. Thanks for the bug report!

alarkun commented 2 years ago

Hi,

I am facing this issue, on version 3.2.4.

Do you have plans to release a new stable version with this fix included?

Thanks a lot!

paulbartrum commented 2 years ago

I had no plans to do so, but ask and you shall receive :-) 3.2.5 is available now.

alarkun commented 2 years ago

Thanks a lot!! You are awesome