I have created the following class I want to serialize into Json:
[JsonObject("user_auth")]
public class CrmAuth
{
[JsonProperty("user_name")]
public string Name { get; set; }
[JsonProperty("password")]
public string Password { get; set; }
}
I am trying to serialize it like:
var serialized = JsonConvert.SerializeObject(crmAuthInstance);
This create this json:
{
"user_name":"login name",
"password":"the password"
}
But what I want is this:
"user_auth" : {
"user_name":"login value",
"password":"password value"
}
Is there a neat way to achieve the serialization with a single class like this?