I have a blob of JSON that I'm reading in C# using the Newtonsoft JSON.NET library. The content within "data" are dynamically named objects. So I won't know when reading the data that the first object might be named "ABC123". Since each one of these objects within "data" has the same schema it would be easiest for me to convert this into an array.
Convert:
data: {
ABC123: { id: 1, name: "Name 1" },
XYZ789: { id: 2, name: "Name 2" },
QRS456: { id: 3, name: "Name 3" },
TUV678: { id: 4, name: "Name 4" }
}
To:
data: [
{ id: 1, name: "Name 1" },
{ id: 2, name: "Name 2" },
{ id: 3, name: "Name 3" },
{ id: 4, name: "Name 4" }
]
How would I do this using JSON.NET? I'm hoping to achieve this using a serialization attribute so that I don't have to loop through the objects.