Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to deserialize a array with indexes that contains arrays in Newtonsoft.Json in c#

I have an API that returns a JSON of this structure:

{
   "1":[
      {
         "name":"One"
      },
      {
         "name":"Two"
      }
   ],
   "2":[
      {
         "name":"Three"
      }
   ]
}

I need to deserialize it in C# using Newtonsoft.Json. I have tried deserializing in a
List<List<Response>> but it didn’t work.

I understand that the JSON is not necessarily good, but I can’t change it since it’s on a third party server.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Every help is appreciated.

>Solution :

Deserialize into a dictionary (or SortedDictionary, if the order of the elements in the dictionary matter), then take the dictionary’s Values collection and run…

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading