-1
我累了有关分析认为JSON响应:如何解析该json响应?
我准备类的东西型号:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Announcements
{
public class Private
{
public string created_at { get; set; }
public int id { get; set; }
public string text { get; set; }
public string title { get; set; }
public string updated_at { get; set; }
public int user_id { get; set; }
}
public class User
{
public string first_name { get; set; }
public int id { get; set; }
public string last_name { get; set; }
}
public class Public
{
public string created_at { get; set; }
public int id { get; set; }
public string text { get; set; }
public string title { get; set; }
public User user { get; set; }
}
public class RootObject
{
public List<Private> @private { get; set; }
public List<Public> @public { get; set; }
}
}
现在是时候反序列化响应:
var tempUsersArray = JsonConvert.DeserializeObject<Announcements.RootObject>(response.Content);
,这使得应用程序崩溃.. 。
任何人都知道我做错了什么?
请提供例外,你有 –
我刚刚测试过你的代码,工作得很好。 – MarcinJuraszek
您可能需要用'[JsonProperty(“”)''装饰您的模型。看看这里:http://stackoverflow.com/q/11126242/2638872 – mrtig