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

C# Json Convert any dynamic object to key value pairs not class

i have a Json

{
   "test1.png": "123",
   "image.png": "456",
   "pdffile.pdf": "789"
}

how can i convert to C# dictionary or table

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

>Solution :

How about this?

string serializedDic = @"{
   ""test1.png"": ""123"",
   ""image.png"": ""456"",
   ""pdffile.pdf"": ""789""
}";

Dictionary<string, string> dict = 
  JsonSerializer
  .Deserialize<Dictionary<string, string>>(serializedDic);
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