Answers for "c# newtonsoft json serialize"

17

object to json c#

using Newtonsoft.Json;

var jsonString = JsonConvert.SerializeObject(obj);
Posted by: Guest on May-29-2020
2

c# newtonsoft json serialize

Account account = new Account
{
    Email = "[email protected]",
    Active = true,
    CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc),
    Roles = new List<string>
    {
        "User",
        "Admin"
    }
};

string json = JsonConvert.SerializeObject(account, Formatting.Indented);
// {
//   "Email": "[email protected]",
//   "Active": true,
//   "CreatedDate": "2013-01-20T00:00:00Z",
//   "Roles": [
//     "User",
//     "Admin"
//   ]
// }

Console.WriteLine(json);
Posted by: Guest on April-27-2021
-2

c# newtonsoft json serialize

public class Account
{
    public string Email { get; set; }
    public bool Active { get; set; }
    public DateTime CreatedDate { get; set; }
    public IList<string> Roles { get; set; }
}
Posted by: Guest on April-27-2021

Code answers related to "c# newtonsoft json serialize"

Code answers related to "Javascript"

Browse Popular Code Answers by Language