在 Wp7 应用程序中使用 JSON.net 反序列化 JSON
我有这样的 JSON 格式:
string jsonFormat = @"{
""Applications"": {
""data"": {
""Application named one"": [
{
""index"" : ""1"",
""name"" : ""One"",
""active"" : ""1"",
""excluded"" : ""false""
}
],
""Application named two"": [
{
""index"" : ""2"",
""forum"" : ""yes"",
}
]
}
}
}";
我到底如何访问 data
childs ?我需要检索名为一个的应用程序
和名为两个的应用程序
- 对于每个应用程序还有属性及其值 - 这些属性因应用程序而异。
直到现在我已经:
JObject resultt= JObject.Parse(jsonFormat);
// get JSON result objects into a list
IList<JToken> results = resultt["Applications"]["data"].Children().ToList();
我查看了 JSON.net 文档,但找不到解决方案......
任何帮助都会非常有用。谢谢。
I have this JSON format:
string jsonFormat = @"{
""Applications"": {
""data"": {
""Application named one"": [
{
""index"" : ""1"",
""name"" : ""One"",
""active"" : ""1"",
""excluded"" : ""false""
}
],
""Application named two"": [
{
""index"" : ""2"",
""forum"" : ""yes"",
}
]
}
}
}";
How exactly I can acces data
childrens ? I need to retreive Application named one
and Application named two
- for each also the attributes with their values - the attributes are different from Application to Application.
Untill now I have:
JObject resultt= JObject.Parse(jsonFormat);
// get JSON result objects into a list
IList<JToken> results = resultt["Applications"]["data"].Children().ToList();
I looked over JSON.net documentation and could not find a solution for this...
Any help will be very usefull. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你正在寻找这样的东西:
基本上这个想法是使用
Value
方法与你期望检索特定 json 元素(JObject,JArray,...)或解析.NET 值(int、string、bool、...)。I think you are looking for something like this:
Basically the idea is to use the
Value
method with the type you are expecting to retrieve a specific json element (JObject, JArray, ...) or parse a .NET value (int, string, bool, ...).