0
{
"code": 0,
"message": "success",
"expense": {
"account_name": "Printing and Stationery",
"paid_through_account_name": "Petty Cash"
}
}
这是我的JSON格式, 而且我试着用下面的类麻烦与JSON解析Windows Phone的
[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; }
}
反序列化它,我调用这个类与follwing的帮助代码
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.
帮助我走出这个问题....
再次感谢@Alexandr ......这样做是正确! :) – Aju
当我尝试将内容放入**文本框**我收到一个错误,指出'System.UnauthorizedAccessException':无效的跨线程访问。我应该怎样做才能纠正这个问题? – Aju
我更新我的答案,检查它 – Alexandr