Skip to content

Instantly share code, notes, and snippets.

@pedrolamas
Created October 1, 2012 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrolamas/3811718 to your computer and use it in GitHub Desktop.
Save pedrolamas/3811718 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using Newtonsoft.Json;
using System;
namespace ConsoleApplication1
{
class Program
{
public static T DeserializeFromJson<T>(string json)
{
T deserializedProduct = JsonConvert.DeserializeObject<T>(json);
return deserializedProduct;
}
static void Main(string[] args)
{
var kk = @"{""My Book List"": [{""ID"":""5"",""TYPE"":""History"",""TITLE"":""Ekannoborti"",""PRICE"":""200"",""IMAGE"":""Ekannoborti.jpg"",""DOWNLOAD LINK"":""http://www.starhostbd.com/""}],""success"":3}";
var container = DeserializeFromJson<DataJsonAttributeContainer>(kk);
Console.WriteLine(container.attributes[0].DOWNLOADLINK);
}
}
public class Attributes
{
public string ID { get; set; }
public string TYPE { get; set; }
public string TITLE { get; set; }
public string PRICE { get; set; }
public string IMAGE { get; set; }
[JsonProperty("DOWNLOAD LINK")]
public string DOWNLOADLINK { get; set; }
}
public class DataJsonAttributeContainer
{
[JsonProperty("My Book List")]
public List<Attributes> attributes { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment