JSON,无法使用key显示所需信息!
我正在使用 android 1.5,目前正在研究 JSON 相关的东西。我在字符串变量str中拥有此信息
{
"UserInfo":
[
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":1},
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":2},
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":3}
]
}
{
"Info":
[
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":5},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":6},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":7},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":8},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":9},
]
}
,我在str中拥有所有这些信息,现在通过使用键(即UserInfo和Info)我想使用信息来显示其所有元素。我该怎么做? 谢谢!
im using android 1.5 and currently working on JSON related stuff. i have this info in a String variable str
{
"UserInfo":
[
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":1},
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":2},
{"LastName":"b","FirstName":"a","Gender":"Male","User: ":3}
]
}
{
"Info":
[
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":5},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":6},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":7},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":8},
{"LastName":"d","FirstName":"c","Gender":"Male","User: ":9},
]
}
i have all this info in str, now by using key (i.e. UserInfo and Info) i wana use info to display all its elements. how can i do that??
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是有关如何处理 JSON 的信息:
http://developer.android.com/reference/org/json/package -summary.html
这里有一些代码示例: http://www.androidcompetencycenter.com/2009 /10/json-parsing-in-android/
Here's information about how to handle JSON:
http://developer.android.com/reference/org/json/package-summary.html
Some code examples here: http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/