Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Newtonsoft.Json;
- public class Test
- {
- public static void Main()
- {
- var testObject = new TestClass
- {
- TestString = "Test",
- TestInteger = 1234
- };
- // turn class into a json string
- // output: { "TestString":"Test", "TestInteger": 1234 }
- var classSerializedToString = JsonConvert.Serialize(testObject);
- // turn string back into class
- TestClass classFromSerializedString = JsonConvert.Deserialize(classSerializedToString);
- }
- }
- public class TestClass
- {
- public string TestString { get; set; }
- public int TestInteger { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement