我是一个使用JSON的新蜜蜂,我不知道如何在Windows Phone中执行序列化和反序列化

时间:2014-10-30 07:39:51

标签: windows-phone-8 json.net

获取链接将是这样的 - http // 192.156.120.192 / Projects / cricket / index.php / api / api

public class Player
{

    public int playerId { get; set; }
    public string playerName { get; set; }
    public string specialization { get; set; }
    public string battingHand { get; set; }
    public string bowlingHand { get; set; }
    public string bowlingType { get; set; }
    public object genericId { get; set; }
    public int homeTeamId { get; set; }
    public int eligibleTeams { get; set; }
    public object imageUrl { get; set; } 
}

public class RootObject 
{ 

    public string methodName { get; set; }
    public int errorCode { get; set; }
    public string errorMessage { get; set; }
    public List<Player> players { get; set; } 
}

1 个答案:

答案 0 :(得分:0)

我正在使用Json.NET,这非常容易

// create a RootObject object
//..

string serializedRoot = JsonConvert.SerializeObject(myRootObject);

RootObject deserializedRoot = JsonConvert.DeserializeObject<Player>(serializedRoot);