how to convert object in string JSON csharp
Code Example - how to convert object in string JSON csharp
var json = new JavaScriptSerializer().Serialize(obj);
csharp serialize json
using System.Text.Json;
//Serialize
var jsonString = JsonSerializer.Serialize(yourObject);
// Deserialize
var obj = JsonSerializer.Deserialize<YourObject>(stringValue);
object to json csharp
using Newtonsoft.Json;
var jsonString = JsonConvert.SerializeObject(obj);
csharp object to json string
Newtonsoft.Json.JsonConvert.SerializeObject(new {foo = "bar"})
string to json csharp
JObject json = JObject.Parse(str);
string json to class csharp
var result = JsonConvert.DeserializeObject<YourClass>(jsonstring);
csharp print object to json
var json = new JavaScriptSerializer().Serialize(ObjectModel);