Search code examples
c#asp.netjsonfirebasejson-deserialization

How to Deserialize this JSON file


I am facing this problem to convert this JSON File. Anybody please tell me how to deserialize this JSON file. https://fasp-ee999.firebaseio.com/Students.json?auth=yB71DWGpZeBBQjvtEvc4yeROXO8zp717W180rlzw

Above is my json file


Solution

  • It looks like a dictionary, sample with .net core 3.1:

    using System.Collections.Generic;
    using System.IO;
    using System.Text.Json;
    
    namespace ConsoleApp1
    {
        public class Data
        {
            public int id { get; set; }
            public string name { get; set; }
        }
    
        class Program
        {
            public static void Main(string[] args)
            {
                var dataToDeserialize = File.ReadAllText("Students.json");
    
                var deserializedResult = JsonSerializer.Deserialize<Dictionary<string, Data>>(dataToDeserialize);
            }
        }
    }