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