elnabo / json2object

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

International characters #82

Closed andraaspar closed 2 years ago

andraaspar commented 2 years ago

Hi,

I am using json2object=3.10.0 in Haxe 4.2.4, targeting PHP. I'm getting an issue where it can't parse international characters. Here's a test case:

class JsonTestCase extends utest.Test {
    function testStringParse() {
        final parser = new JsonParser<String>();
        var result = parser.fromJson('"á"');
        if (parser.errors.length > 0) {
            throw new Exception(parser.errors.join('\n'));
            // ParserError(Unclosed string,{ file : , min : 1, max : 5, lines : [{ number : 1, start : 1, end : 4 }] })
        }
        Assert.equals("á", result);
        // expected "á" but it is null
    }
}

Some ad-hoc testing shows that the same happens with all the following characters:

©£áéíóöőúüűښж螄💁‍♀️
elnabo commented 2 years ago

Hello, this seems to be a problem related to the parsing library that affect php & cpp.

I've submitted a PR https://github.com/nadako/hxjsonast/pull/11

andraaspar commented 2 years ago

Thank you for looking into it.

andraaspar commented 2 years ago

OK, that fixed it for me: I was able to install from github using lix. Thank you!

lix install github:nadako/hxjsonast#c1e6e9951805674a92963ff7ecd3d7c76534ce2e

However, I see that you have no version specified in haxelib.json. Lix installed the library from haxelib by default. People will keep running into this unless nadako publishes another release. I see that he's not very keen on releases. Is there something here that I don't get about the Haxe ecosystem or should we get him to make a release?

elnabo commented 2 years ago

There is no minimum version required as the current version on haxelib works in many cases. There is the alternative of using directly the git version using haxelib git or haxelib dev

I have asked in the PR if he could make a release on haxelib.

andraaspar commented 2 years ago

Thank you for this. I did the same as a bug report: https://github.com/nadako/hxjsonast/issues/12