-1
저는 JSon, 특히 JSon.Net을 처음 사용합니다. Windows Phone에서 LiveSDK를 사용하려고하는데 JSon 응답을 구문 분석하는 데 문제가 있습니다. 나는 캘린더 정보를 읽으려고하는데 파싱 할 수 없다. 아래는 Json과 클래스 정의를 다운로드하기위한 코드이다. 나는 '사용자'를 정의하는 줄에서 예외를 얻는다.JSon.Net을 사용하여 LiveSDK 캘린더를 비 직렬화
void getCal_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e)
{
if (e.Error == null)
{
using (var reader = new StreamReader(e.Result))
{
var json = reader.ReadToEnd();
var user = JsonConvert.DeserializeObject<Calendar>(json);
}
}
}
JSON 형식 수신
[JsonObject(MemberSerialization.OptIn)]
public class Calendar
{
[JsonProperty(PropertyName="name")]
public string Name{get; set;}
[JsonProperty(PropertyName = "id")]
public string Id{get; set;}
[JsonProperty(PropertyName = "description")]
public string Description{get; set;}
[JsonProperty(PropertyName = "created_time")]
public string CreatedTime{get; set;}
[JsonProperty(PropertyName = "updated_time")]
public string UpdatedTime{get; set;}
[JsonProperty(PropertyName = "from")]
public object From{get; set;}
[JsonProperty(PropertyName = "is_default")]
public bool IsDefault{get; set;}
[JsonProperty(PropertyName = "subscription_location")]
public string SubscriptionLocation{get; set;}
[JsonProperty(PropertyName = "permissions")]
public string Permissions{get; set;}
}
내 달력 클래스 I는 LiveSDK GetAsync() 그래서를 사용하여 더 가진 행운이 함께 갔다되지 않았다
{
"data": [
{
"id": "calendar.42d4dbc866f94c83849c88c6eb9985bc",
"name": "Birthday calendar",
"description": "If you have birthdays listed for your contacts, they'll appear on this calendar. You can add more birthdays, but you can't add other types of events.",
"created_time": "2011-08-05T19:41:04+0000",
"updated_time": "2011-08-05T19:41:04+0000",
"from": {
"name": null,
"id": null
},
"is_default": false,
"subscription_location": null,
"permissions": "read"
},{
...
}
] } 대신 다운로드 Async(). 이 접근법이 더 좋은가요?
감사
이봐, 정말 감사합니다. 나는 그것을 시도했지만 작동하지 않는다고 맹세했지만, 이제는 모두 잘됐다. – lucasbrendel