I’m looking for advice on the best way to represent this JSON object in C#.
To be clear, I’m not trying to convert from an existing JSON string to C# object – this is from scratch. I can visualize what I’m trying to create as JSON, but not sure how that translates…
[
{
"EquipmentID": "ASD2F",
"ConnectionIDs":[
{ "ConnectionID": "HD4GH" },
{ "ConnectionID": "KAFD3" },
{ "ConnectionID": "NA3AF" }
]
},
{
"EquipmentID": "GAE31",
"ConnectionIDs":[
{ "ConnectionID": "HJA03" },
{ "ConnectionID": "FGVA1" },
{ "ConnectionID": "GHAD8" }
]
}
]
That’s basically an array of EquipmentID’s, each EquipmentID containing an array of ConnectionID’s. I’ve been tinkering with a few different Classes containing arrays, lists, etc… but I can’t seem to settle on anything. I know this should be incredibly simple, so thanks in advance for helping out!
Something like this makes sense:
Then you’d have a variable of type
List<Equipment>to hold the equipments.By the way, it’s not clear to me whether
ConnectionIdsthemselves are equipments or not. If they are, you’d basically have: