如何从JavaVK Longpool中的JSON数组中获取元素?

问题描述

当我联系VKontakte.com服务器以接收长池请求的数据时,会收到以下响应:

Array
(
    [response] => Array
        (
            [key] => 3frf4b6e17478cеf5c463c4f14a5afcd93208412a
            [server] => https://lp.vk.com/wh123264621
            [ts] => 15
        )

)

如何从org.json获取Java中的所有这些参数?

我的代码

import org.json.*;

public class test123 {
    public static void main(String args[]){
        String json = "{"response":{"key":"12312","server":"12312312","ts":"231"}}"; // (with `\` before ` " ` )

        JSONObject o = new JSONObject(json);
        JSONArray a = o.getJSONArray("response");
        String out = (String) a.get("key");
        System.out.println(out);
    }
}

,它肯定不起作用,因为a.get需要一个int。如何使其成为``关联的''

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)