我正在計劃代理中工作。我在schedule agent中有json格式的數據。我在日程代理中嘗試了Json.net將json反序列化爲列表,但它在日程代理中不起作用。反序列化json數據而不使用Json.net
任何人都可以告訴我如何可以反序列化JSON數據到列表格式而不使用Jsonssoft.dll?
我使用下面的代碼轉換JSON到列表中,但它給我的childList空...
List<ConferenceModel> childlist = new List<ConferenceModel>();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(responseContent));
DataContractJsonSerializer ser = new DataContractJsonSerializer(childlist.GetType());
childlist = ser.ReadObject(ms) as List<ConferenceModel>;
這裏是ConferenceModel類
public class Conference
{
public string id { get; set; }
public string datetime { get; set; }
public string updateDateTime { get; set; }
public int duration { get; set; }
public string description { get; set; }
private bool _isEditDeleteVisible;
}
public class ConferenceModel
{
public List<Conference> conferences { get; set; }
}
確實WP8有['DataContractJsonSerializer'(http://msdn.microsoft.com/en-us/library/system。 runtime.serialization.json.datacontractjsonserializer(v = vs.110)的.aspx)? –
是的,在WP8 DataContractJsonSerializer在那裏。我如何使用它? –
嗯...如果需要添加引用;如果需要添加'using'指令;那麼只需'new'' DataContractJsonSerializer'並按照MSDN中的示例使用它。 –