0

I'm using Newtonsoft.Json to read a .json file. I need to generically --> It should loop through all the datas where data/count may vary every time.

//var map=new Dictionary<string,string>();
using (StreamReader file = File.OpenText(filepath)){
    using (JsonTextReader reader = new JsonTextReader()){
        JObject obj = (JObject)JToken.ReadFrom(reader);

        while (Reader.read()){
            for (int i = 0; i < reader.lineNumber; i++){
                if (reader.value != null)
                    Console.Writeline("Token{i},Tokem{1}", reader.TokenType, reader.TokenValue);
                else
                    Console.Writeline("Token{i}", reader.TokenValue);

                i++;
            }
        }
    }
}

How to get these console values returned in a Dictionary/List to make it generic?

Al Imran
  • 882
  • 7
  • 29
  • `JsonConvert.DeserializeObject>(File.ReadAllText(filepath));`? Could you please share the JSON your are trying to deserialize? – Tobias Tengler Dec 02 '18 at 14:25
  • Actually I don't have any JSON file as of now. I'm writing framework from the scratch. So the code should loop through all datas in .json file. I didn't work with json before. I have created data access layer to read excel, xml, csv, sqlhelper, etc. and used dictionary to get data from each files. But i don't have idea to read data from json.. – meena priyanka Dec 02 '18 at 14:43

0 Answers0