日期:2014-05-17 浏览次数:20612 次
class Program
{
public static void Main(string[] args)
{
string json1 = "{\"errorCode\":\"0\",\"errorMessage\":\"\",\"data\":\"hMGoq65YJmjBJwvbYoDr4XsUPg5tvbaN3SY26UM4cViRo8jkG5v6C1rlRMs23mZg\"}";
Data1 data1 = JsonConvert.DeserializeObject<Data1>(json1);
Console.WriteLine(string.Join(",", data1.ErrorCode, data1.ErrorMessage, data1.Data));
string json2 = "[{\"productId\":\"test12560003\",\"itemId\":\"125600030001\",\"supplyPrice\":999.99,\"marketPrice\":1000.99,\"sellPrice\":1000.99},{\"productId\":\"thisisatestdata\",\"itemId\":\"thisisatestdata7\",\"supplyPrice\":69.88,\"marketPrice\":70.88,\"sellPrice\":70.88}]";
List<Data2> list = JsonConvert.DeserializeObject<List<Data2>>(json2);
foreach (var item in list)
{
Console.WriteLine(string.Join(",", item.ProductId, item.ItemId, item.SupplyPrice, item.MarketPrice, item.SellPrice));
}
}
}
public class Data1
{
public string ErrorCode { get; set; }
public string ErrorMessage { get; set; }
public string Data { get; set; }
}
public class Data2
{
public string ProductId { get; set; }
public string ItemId { get; set; }
publ