Articles → .NET → Read JSON text using newtonsoft JSON library in C#

Read JSON text using newtonsoft JSON library in C#






Installing library




Picture showing adding the json.net using Nuget

Click to Enlarge


Read JSON




using Newtonsoft.Json;
using System;

namespace ReadJson {
  class Program {
    static void Main(string[] args) {
      string json = "{\"Name\": \"Karan Gupta\",\"Age\": 28,\"Technology\": \"JSON\",\"Address\":{\"City\": \"Gurgaon\",\"State\": \"Haryana\"}}";

      dynamic jsonObj = JsonConvert.DeserializeObject(json);

      Console.WriteLine(jsonObj.Name);
      Console.ReadLine();

    }
  }
}



Output


Picture showing the output of reading JSON text using newtonsoft JSON library in C#

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, March 10, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250