Home > Software engineering >  Need ideas how to parse the following JSON format
Need ideas how to parse the following JSON format

Time:03-15

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?

CodePudding user response:

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);
  • Related