rcdmk / aspJSON

A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.
MIT License
203 stars 89 forks source link

Negative values parsed as positive #15

Closed mvlaran closed 8 years ago

mvlaran commented 8 years ago

Hi!

I have an issue: when parsing the following JSON, which has negative numeric values:

{""item1"":""textvalue"",""item2"":{""subitem1"":{""subitem1subitem1"":-2.3,""subitem1subitem2"":-4.6}},""item3"":""textvalue"",""item4"":""textvalue"",""item5"":""textvalue"",""item6"":{""subitem1"":false,""subitem2"":[]},""item7"":[{""subitem1"":467,""subitem2"":[""arraytextvalue""],""subitem3"":""textvalue"",""subitem4"":700}],""item8"":""textvalue"",""item9"":4.4,""item10"":""textvalue"",""item11"":[""arraytextvalue1"",""arraytextvalue2"",""arraytextvalue3""]}

It is parsing the negative values as positive values:

Open value for "subitem1subitem1" Open numeric value Close numeric value: 2.3 Value converted to number Value added: "subitem1subitem1" ... Open value for "subitem1subitem2" Open numeric value Close numeric value: 4.6 Value converted to number Value added: "subitem1subitem2"

I have made the following change in the code, in the line 290:

if prevchar = "-" then value = prevchar & char else value = char end if

And that seems to resolve it, but you should take a better look into it.

Thanks

rcdmk commented 8 years ago

Hi. Thank you for your suggestion. I should take a look at this soon.