public void Shortenning() { var sut = new JsonSerializationBuilder() .UseShortTypeNames(typeof(BlogInfo), typeof(BlogPost)) .UsePrettyFormat() .Build(); var data = BlogInfo.Create(); var bytes = sut.Serialize(data); var s = Encoding.UTF8.GetString(bytes); Assert.Contains("BP.", s); var data2 = sut.Deserialize(bytes); Assert.True(data2 is BlogInfo); }
public void Shortenning2() { var sut = new JsonSerializationBuilder() .UseShortTypeNames(typeof(BlogInfo), typeof(BlogPost), typeof(Dictionary <string, object>)) .UsePrettyFormat() .Build(); var data = new Dictionary <string, object> { { "AAA", BlogInfo.Create() }, { "BBB", 125.95 }, { "CCC", new[] { "fff", "eee" } }, { "DDD", BlogPost.Create() }, }; var bytes = sut.Serialize(data); var s = Encoding.UTF8.GetString(bytes); var data2 = sut.Deserialize(bytes); }