c# json to string online code example
Example 1: c# json convert
jsonString = File.ReadAllText(fileName);
weatherForecast = JsonSerializer.Deserialize<WeatherForecast>(jsonString);
Example 2: json to csharp
public static T Deserialize(string serializedData)
{
var deJson = JsonConvert.DeserializeObject<T>(serializedData);
return deJson;
}
public static string Serialize(object objectName)
{
var settings = new JsonSerializerSettings()
{
ContractResolver = new OrderedContractResolver()
};
var json = JsonConvert.SerializeObject(objectName, Formatting.Indented, settings);
return json;
}
public static string Serialize(object objectName)
{
var json = JsonConvert.SerializeObject(objectName, Formatting.Indented);
return json;
}