elnabo / json2object

Type safe Haxe/JSON (de)serializer
MIT License
66 stars 17 forks source link

UInt support #53

Closed Gama11 closed 5 years ago

Gama11 commented 5 years ago

UInt currently seems to be serialized as a regular Int:

class Main {
    static function main() {
        var i:UInt = 0x80000000;
        trace(i); // 2147483648
        trace((i : Int)); // -2147483648

        var data:Data = {i: i};
        // outputs {"i": -2147483648}, but should be {"i": 2147483648}
        trace(new json2object.JsonWriter<Data>().write(data)); 
    }
}

typedef Data = {
    var i:UInt;
}

Support for UInt may need to be hardcoded, considering the abstract allows an implicit to Int.

elnabo commented 5 years ago

UInt support has been improved in b5461df522810be6515f12a61b157bc5d2bf3ae2.