I receive the following Json through a web service:
{
report: {
Id: "aaakkj98898983"
}
}
I want to get value of the Id. How to do this in C#? THANKS
I receive the following Json through a web service:
{
report: {
Id: "aaakkj98898983"
}
}
I want to get value of the Id. How to do this in C#? THANKS
First, download Newtonsoft's Json Library, then parse the json using JObject. This allows you to access the properties within pretty easily, like so:
using System;
using Newtonsoft.Json.Linq;
namespace testClient
{
class Program
{
static void Main()
{
var myJsonString = "{report: {Id: \"aaakkj98898983\"}}";
var jo = JObject.Parse(myJsonString);
var id = jo["report"]["Id"].ToString();
Console.WriteLine(id);
Console.Read();
}
}
}