Articles → JSON → Read JSON using Newtonsoft in C#

Read JSON using Newtonsoft in C#






Prerequisite




Install-package Newtonsoft.json –version 9.0.1



Code




using Newtonsoft.Json;

namespace ReadJson
{
    class Program
    {
        static void Main(string[] args)
        {
            string json = @"{
                    Name: 'Karan Gupta',
                    Age: 28,                    
                    Address: 'India'
                }";

            Data data = JsonConvert.DeserializeObject<Data>(json);

        }
    }
    public class Data
    {
        public string Name{ get; set; }
        public int Age{ get; set; }
        public string Address { get; set; }
    }    
}



Output



Click to Enlarge

Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, May 01, 2018

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250