【发布时间】:2013-10-16 05:28:56
【问题描述】:
{
"code": 0,
"message": "success",
"expense": {
"account_name": "Printing and Stationery",
"paid_through_account_name": "Petty Cash"
}
}
这是我的json格式, 我正在尝试使用以下类对其进行反序列化
[DataContract]
public class Expenses
{
[DataMember(Name = "code")]
public int Code { get; set; }
[DataMember(Name = "message")]
public string Message { get; set; }
[DataMember(Name = "expense")]
public Expense Expense { get; set; }
}
[DataContract]
public class Expense
{
[DataMember(Name = "account_name")]
public string Account_Name { get; set; }
[DataMember(Name = "paid_through_account_name")]
public int Paid_Through_Account_Name { get; set; }
}
我在以下代码的帮助下调用这个类
var myObjects = JsonConvert.DeserializeObject<Expenses>(json);
但在执行上述行时,我总是收到一个错误提示,
An exception of type 'System.UnauthorizedAccessException' occurred in PhoneApp18.DLL but was not handled in user code
If there is a handler for this exception, the program may be safely continued.
帮助我摆脱这个问题......
【问题讨论】:
标签: c# json windows-phone-7 json-deserialization