首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更新TextView的Json字符串

更新TextView的Json字符串
EN

Stack Overflow用户
提问于 2012-04-29 12:05:10
回答 1查看 327关注 0票数 0

我想从数据库中提取一个JSON字符串,然后更新一个textview.My Json字符串,如下所示:

代码语言:javascript
复制
[
    {
        "meaning": "A boy or young man (often as a form of address)",
        "examples": [
            "I read that book when I was a <em>lad</em>",
            "come in, <em>lad</em>, and shut the door"
        ]
    },
    {
        "meaning": "A group of men sharing recreational, working, or other interests",
        "examples": [
            "she wouldn't let him go out with the <em>lads</em> any more"
        ]
    },
    {
        "meaning": "A man who is boisterously macho in his behavior or actions, esp. one who is interested in sexual conquest",
        "examples": [
            "Tony was a bit of a <em>lad</em>âalways had an eye for the women"
        ]
    },
    {
        "meaning": "A stable worker (regardless of age or sex)",
        "examples": []
    }
]

我只想提取“意思”.How我能做到吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-29 12:09:34

首先,这是一个JSON数组,里面有许多meaning

你可以像这样迭代它:

代码语言:javascript
复制
JSONArray jarr = new JSONArray(theJsonString);
for (int i = 0; i < jarr.length(); ++i)
{
    JSONObject jCell = jarr.getJSONObject(i);
    String meaning = cell.getString("meaning");
    // set it as text? concatenate the strings?
}

注意:

为了保持代码清晰,我没有处理异常,请在你的代码中这样做。有关JSON format.

  • The的更多信息,

  • 阅读以下类是JSON format.

  • The的一部分:JSONArrayJSONObject.

  • Worth

  • ,下一次你将不必再问:)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10369599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档