object to json c#
snippet in javascript

object to json c#

user2391

using Newtonsoft.Json;

var jsonString = JsonConvert.SerializeObject(obj);

c# serialize json

user3713

using System.Text.Json;

//Serialize
var jsonString = JsonSerializer.Serialize(yourObject);

// Deserialize
var obj = JsonSerializer.Deserialize<YourObject>(stringValue);

c# object to json string

user4931

Newtonsoft.Json.JsonConvert.SerializeObject(new {foo = "bar"})

how to convert object in string JSON c#

user9718

var json = new JavaScriptSerializer().Serialize(obj);

c# convert object to json

user1420

var jsonString = JsonConvert.SerializeObject(ObjectModel);