neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.36k stars 267 forks source link

Can't deserialize Class with multibyte name #136

Open medamap opened 5 years ago

medamap commented 5 years ago

I attempted to deserialize class with multibyte name with utf8json. I expected that it will be properly deserialized, but it did not happen.

sample script

using System;
using UnityEngine;
using Utf8Json;

public class multibytetest : MonoBehaviour {

    [Serializable]
    public class 漢字クラス {
        public string 亜;
        public string 伊宇江;
        public string 尾華;
        public string 機;
    }

    [SerializeField]
    public 漢字クラス multibyte;

    // Use this for initialization
    void Start () {
        var json = @"{""亜"":""a"",""伊宇江"":""b"",""尾華"":""c"",""機"":""d""}";
        multibyte = JsonSerializer.Deserialize<漢字クラス>(json);
    }

}

Result image

It is considered that the processing of the second field is not processed normally. The second field key has 9 bytes, but the AutomataDictionary.GetKey method is called only once. With my expectation, I think that rest is called 8 for the first time, and rest is called 1 for the second time.

If deserialize with Dictionary type, it will work.

Thank you.