Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Program
- {
- class A { }
- class B { }
- public static void Main()
- {
- Dictionary<string, object> dict = new Dictionary<string, object>();
- dict["Foo"] = new A();
- dict["Bar"] = new B();
- dict["Baz"] = new object();
- dict["Rainbow"] = Color.FromArgb(20, 20, 20, 20);
- var ser = new JsonSerializer
- {
- TypeNameHandling = TypeNameHandling.Auto
- };
- var w = new JsonTextWriter(Console.Out)
- {
- Formatting = Formatting.Indented
- };
- ser.Serialize(w, dict);
- }
- }
- {
- "Foo": {
- "$type": "Program+A, mi1i2eqo"
- },
- "Bar": {
- "$type": "Program+B, mi1i2eqo"
- },
- "Baz": {},
- "Rainbow": "20, 20, 20, 20"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement