私はJSON出力を受け取ってさまざまなことを行うために、(RESTサービスを使用して)Open Weather Map(OWM)サービスを呼び出すために使用できるシンプルなアプリケーションに取り組んでいます。 EclipseでSpring MVCフレームワークを使用していますが、JSON出力を取得できますが、取得するすべてのものがNULLとして出力されます。 OWMが私のAPIキーを私がそれを呼び出す方法から認識しないこととは関係があると感じています。どのポインタも素晴らしいでしょう。また、OWM Webサイトのソリューションとパラターのセクションで提供されているOWM Javaライブラリを利用しています。Spring MVCを使用して天気図を開く
@GetMapping(value = "/current/{city}")
public ResponseEntity currentWeather(@PathVariable("city") String city) throws MalformedURLException, JSONException, IOException{
//String apiKey = "**myAPIKey**";
OpenWeatherMap openWMap = new OpenWeatherMap("**myAPIKey**");
openWMap.getApiKey();
CurrentWeather currentW = openWMap.currentWeatherByCityName("Berlin");
return new ResponseEntity(currentW, HttpStatus.OK);
}
}
と私の出力Iは、温度を得ることができるかのように私は感じて正しいJSONレスポンスを取得する方法を見つけ出すことができれば
{
"responseCode": -2147483648,
"rawResponse": null,
"dateTime": null,
"weatherCount": 0,
"cityName": null,
"coordInstance": null,
"mainInstance": null,
"rainInstance": null,
"sysInstance": null,
"windInstance": null,
"baseStation": null,
"cityCode": -9223372036854775808,
"cloudsInstance": null,
"valid": false
}
のように見えますそしてそれは妥当な容易さではない。どんなポインタであれ大いに感謝します!