反序列化JSON对象Xamarin Android C# [英] Deserialize json object xamarin android c#
本文介绍了反序列化JSON对象Xamarin Android C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我反序列化json对象几乎没有问题. 我来自http网址的json:
I have little issue with deserialize json object. My json from http url:
我不知道如何反序列化以动态创建按钮.我想出了如何用文本创建按钮,但是我不知道如何使用它们所具有的选项来创建按钮.我尝试在Windows Form应用程序中获取这些选项进行测试,但应用程序将崩溃.谢谢您的帮助.
I don't know how to deserialize to make dynamically creating buttons. I figure out how to create buttons with text, but I don't know how to make them with options that they have. I try to get these options in Windows Form app for test, but app will crash. Thank you for help.
推荐答案
您的类应类似于:
public class Type
{
public int id { get; set; }
public string name { get; set; }
public bool closedQuestion { get; set; }
public bool multiAnswer {get; set;}
public bool usesImage {get; set; }
}
public class RootObject
{
public int id { get; set; }
public string name { get; set; }
public Type type { get; set; }
public List<string> options { get; set; }
}
然后,您应该可以使用Newtonsoft.Json反序列化json:
Then you should be able to deserialize your json, using Newtonsoft.Json:
List<RootObject> myData = JsonConvert.DeserializeObject<List<RootObject>>(json);
这篇关于反序列化JSON对象Xamarin Android C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文