Created
October 1, 2012 13:12
-
-
Save pedrolamas/3811718 to your computer and use it in GitHub Desktop.
Solution for http://stackoverflow.com/questions/12671962/deserializing-json-in-windows-phone-7-using-json-net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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