create c# class from json code example
Example 1: how to create object in php wihtout class
$object = new stdClass();
$object->property = 'Here we go';
var_dump($object);
$object = (object) ['property' => 'Here we go'];
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;
}
Example 3: javascript create class
class Car {
constructor(brand) {
this.carname = brand;
}
}
Example 4: c# create a json object
dynamic ret = new JObject();
ret = new JObject(new JProperty("vendorDetails", new JObject()));
ret.vendorDetails.Add(new JProperty("vendorName", "Vendor Name"));