i'm using this class :
class message
{
public content Content { get; set; }
public from From { get; set; }
public personalizations Personalizations { get; set; }
}
public class content
{
public string type = "text/html";
public string value = "html";
}
public class from
{
public string email = "example@example.com";
public string name = "example";
}
public class personalizations
{
public List<to> tos { get; set; }
}
public class to
{
public string subject { get; set; }
public string email { get; set; }
}
i'm serializing the class Message to :
var msg = new message() { Content = new content() { type = "text/html", value = "html" },
From = new from() { email = "example@example.com", name = "example" },
Personalizations = new personalizations() { tos = new List<to>() { new to(), new to() } } };
var data = JsonConvert.SerializeObject(msg);
i'm trying to get an array of every parent the json output format is
{
"Content": {
"type": "text/html",
"value": "html"
},
"From": {
"email": "example@example.com",
"name": "example"
},
"Personalizations":
{
"tos": [
{
"subject": null,
"email": null
},
{
"subject": null,
"email": null
}
]
}
}
but i do want this format instead :
{
"content": [
{
"type": "text/html",
"value": "Html"
}
],
"from": {
"email": "",
"name": ""
},
"personalizations": [
{
"subject": "",
"to": [ { "email": "" }]
},
{
"subject": "",
"to": [{ "email": "" }]
},
{
"subject": "",
"to": [{ "email": "" }]
}
]
}
how can i manage to do change the format to the last one ?
thanks in advance
EDIT :
i want to change the format not the values example :
in the last json example i have a object of personalization wich hold multiple json but in the first one i only have an object