String str = "[ { "hotword": "向艳梅斩获金牌", "url": "http://m.yz2.sm.cn/s?q=%E5%90%91%E8%89%B3%E6%A2%85%E6%96%A9%E8%8E%B7%E9%87%91%E7%89%8C&by=hot&from=wm" }, { "hotword": "傅园慧网络直播", "url": "http://m.yz2.sm.cn/s?q=%E5%82%85%E5%9B%AD%E6%85%A7%E7%BD%91%E7%BB%9C%E7%9B%B4%E6%92%AD&by=hot&from=wm" }, { "hotword": "亲哥偷走23万", "url": "http://m.yz2.sm.cn/s?q=%E4%BA%B2%E5%93%A5%E5%81%B7%E8%B5%B023%E4%B8%87&by=hot&from=wm" } ]";
public class Bean { private String hotword; private String url; public String getHotword() { return hotword; } public void setHotword(String hotword) { this.hotword = hotword; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } }
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Bean bean = gson.fromJson(jsonString, new TypeToken<List<Bean>>(){}.getType()); 或者 Bean bean = gson.fromJson(jsonString,Bean.class);
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232456.html原文链接:https://javaforall.net
