Skip to content

.NET Serialization an object type to/from a string/json

License

Notifications You must be signed in to change notification settings

mustaddon/TypeSerialization

Repository files navigation

TypeSerialization NuGet version

Serialization an object type to/from a string

Features

  • Generics support
  • URI safe format

Example 1: Serialization

var str = TypeSerializer.Serialize(typeof(Dictionary<int,string>));
Console.WriteLine(str);

// Console output: 
// Dictionary(Int32-String)

Example 2: Deserialization

var deserializer = new TypeDeserializer(/* add your possible types for resolving */);
var type = deserializer.Deserialize("Dictionary(Int32-String)");
Console.WriteLine(type);

// Console output: 
// System.Collections.Generic.Dictionary`2[System.Int32,System.String]

Program.cs