JWambaugh / TJSON

The tolerant JSON parser for Haxe
78 stars 25 forks source link

Error on parsing Float #31

Open KanedaFr opened 4 years ago

KanedaFr commented 4 years ago

exception on parsing a float value. since float use "," also the key:value separator

to fix (sorry, I don't know how to make a PR) replace

if (inSymbol){
    if(c==' ' || c=="\n" || c=="\r" || c=="\t" || c==',' || c==":" || c=="}" || c=="]"){ //end of symbol, return it
        pos--;
        return symbol;
    }
    else{
        symbol+=c;
        continue;
    }

by

if (inSymbol){
    if(c==' ' || c=="\n" || c=="\r" || c=="\t" || c==":" || c=="}" || c=="]"){ //end of symbol, return it
        pos--;
        return symbol;
    }
    else if(c==","){
        //i doubt pos > json.length in this case
        var c2 = json.charAt(pos);
        if ((c2 >= '0') && (c2<= '9'))
        {
            symbol+=c;
            continue;
        }
        else 
        {
            //not in float
            pos--;
            return symbol;
        }
    }
    else{
        symbol+=c;
        continue;
    }

HTH