1

I have an API that returns JSON data in the following structure:

{
  "85f78300-d993-4b7e-a8d0-8d39a4ba9d2a": {},
  "4000fda7-18af-463f-b694-bbafe5d23a48": {
    ...
  }
  ...
}

It should represents a list of objects referenced by a GUID. Typically a list of of Objects would look like this:

{
  "objects": [
     {...},
     {...},
     ...
  ]
}

Currently I have no clue how to parse this result properly. Does anyone have a clue for me?

SaschaLeh
  • 198
  • 9
  • Install JSON.NET via NuGet ([see how](https://stackoverflow.com/questions/4444903/how-to-install-json-net-using-nuget)) and use that to parse your JSON. – Wyck Mar 14 '22 at 14:53

1 Answers1

5

You could treat it as a Dictionary<Guid, object>. You can replace object with your data type.

string json = "{\"85f78300-d993-4b7e-a8d0-8d39a4ba9d2a\": {\"prop\": \"value\"}}";
        
var dict = System.Text.Json.JsonSerializer.Deserialize<Dictionary<Guid, object>>(json);
Ivan Aguilar
  • 565
  • 1
  • 7
  • 22