D.Ordas
D.Ordas

Reputation: 53

ServiceStack.Text version 5.4.0 default char value serialization and deserialization

This happends JsonSerializer but not with TypeSerializer.

Default char serialization is "\u0000" but deserialization of that string into char is '\'.

Is this a bug? or I am missing something?

Any workaraound? maybe some JsConfig.SerializeFn and JsConfig.DeSerializeFn?

I have done a simple program to test it:

public class MyObj
{
    public char AChar { get; set; }
}

public static void Main(string[] args)
{
    var obj = new MyObj();
    var json = obj.ToJson();
    System.Console.WriteLine(json);

    var newObj = json.FromJson<MyObj>();

    if (newObj.AChar == obj.AChar)
        System.Console.WriteLine("Ok!");
    else
        System.Console.WriteLine(newObj.ToJson());

}

Thanks!

Upvotes: 1

Views: 43

Answers (1)

mythz
mythz

Reputation: 143319

This issue should now be resolved from this commit.

This change is available from v5.4.1 that's now available on MyGet.

Upvotes: 1

Related Questions