I have to serialize into json some informations and then write them to a file. Actually the result i want to achieve is this:
{
"Email": "[email protected]",
"Active": true,
"CreatedDate": "2013-01-20T00:00:00Z",
"libraries": [
{
"name": "name1"
},
{
"name": "name2"
}
]
}
this is the class i use to store info:
public class JSON
{
public string Email { get; set; }
public bool Active { get; set; }
public DateTime CreatedDate { get; set; }
public string[] libraries { get; set; }
}
and then i use this to serialize them:
JSON account = new JSON
{
Email = "[email protected]",
Active = true,
CreatedDate = new DateTime(2013, 1, 20, 0, 0, 0, DateTimeKind.Utc),
libraries = new[] {"Small","Medium","Large" }
};
string json = JsonConvert.SerializeObject(account, Formatting.Indented);
the problem is that actually the result i have is this:
{
"Email": "[email protected]",
"Active": true,
"CreatedDate": "2013-01-20T00:00:00Z",
"libraries": [
"Small",
"Medium",
"Large"
]
}
how can i solve it?