I want to serialize properties but with each property enclosed in a separate JSON object in an array.
Example below:
public class Metadata
{
public string Name { get; set; }
public Guid Id { get; set; }
}
public void SerializeCars()
{
var data = new Metadata { Name = "MyName", Id = Guid.NewGuid() };
var json = JsonConvert.SerializeObject(data, Formatting.Indented);
}
Current result will be:
{
"Name": "MyName",
"Id": "f9c4bc06-0b99-47ff-b22b-ea094fc188ee"
}
I want it to be (missing "td" class above):
{
"td": [{
"name": "myName"
}, {
"id": "f9c4bc06-0b99-47ff-b22b-ea094fc188ee"
}]
}
Can it be fixed?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…