【问题标题】:JSONArray and JSONObject for google calendar谷歌日历的 JSONArray 和 JSONObject
【发布时间】:2011-05-16 16:06:22
【问题描述】:

我正在尝试创建一个 android 应用程序以使用 json 输出从谷歌日历读取信息。

http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json

谁能告诉我如何使用 android sdk 中提供的 JSONArray 和 JSONObject 选项来完成这项工作。

非常感谢您对此的任何帮助...

提前谢谢...

【问题讨论】:

    标签: android json google-calendar-api


    【解决方案1】:

    这是一个例子

    // Query the API for content
            String content = getUrlContent(String.format(WIKTIONARY_PAGE,
                    encodedTitle, expandClause));
            try {
                // Drill into the JSON response to find the content body
                JSONObject response = new JSONObject(content);
                JSONObject query = response.getJSONObject("query");
                JSONObject pages = query.getJSONObject("pages");
                JSONObject page = pages.getJSONObject((String) pages.keys().next());
                JSONArray revisions = page.getJSONArray("revisions");
                JSONObject revision = revisions.getJSONObject(0);
                return revision.getString("*");
            } catch (JSONException e) {
                throw new ParseException("Problem parsing API response", e);
            }
    

    【讨论】:

    • 感谢您的快速响应。我会试试这个并分享我的经验。再次感谢...!!!
    • 谢谢,如果对您有帮助,您可以选择我的答案。
    • 我在谷歌日历 json 输出中没有看到节点查询。我看到节点“条目”。我怎样才能解析这个以获得所需的信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-15
    • 2016-02-16
    相关资源
    最近更新 更多