【发布时间】:2013-11-26 19:33:55
【问题描述】:
问题来了,我正在使用 Wunderground 的天气 APi,但在使用 GSON 获取天气时遇到了问题。
import java.net.*;
import java.io.*;
import com.google.gson.*;
public class URLReader {
public static URL link;
public static void main(String[] args) {
try{
open();
read();
}catch(IOException e){}
}
public static void open(){
try{
link = new URL("http://api.wunderground.com/api/54f05b23fd8fd4b0/geolookup/conditions/forecast/q/US/CO/Denver.json");
}catch(MalformedURLException e){}
}
public static void read() throws IOException{
Gson gson = new Gson();
// Code to get variables like humidity, chance of rain, ect...
}
}
就我所知,有人可以帮我解决这个问题。我需要能够解析特定变量,而不仅仅是整个 JSON 文件。
我使用了缓冲阅读器,但它读取了整个 JSON 文件。
在此先感谢,我是初学者,所以要简单明了地解释事情:)
【问题讨论】:
标签: java json api gson wunderground