Serialize object into JSON
suggest changeusing Newtonsoft.Json;
var obj = new Person
{
Name = "Joe Smith",
Age = 21
};
var serializedJson = JsonConvert.SerializeObject(obj);
Person is a type with public Name and Age properties. This results in this JSON: {"Name":"Joe Smith","Age":21}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents