2017-01-04 11 views
0

予測を表示するRetrofitなしでアプリケーションを作成する必要があります。私はいくつかの例外があります。これは私のコードです:com.google.gson.stream.MalformedJsonException:予期された ':'行1の列55のパス

import android.os.AsyncTask; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.util.Log; 
import android.widget.ImageView; 
import android.widget.TextView; 
import com.google.gson.Gson; 
import com.google.gson.GsonBuilder; 

import org.json.JSONException; 
import org.json.JSONObject; 

import java.io.IOException; 
import java.util.HashMap; 
import java.util.Map; 
import retrofit2.Call; 
import retrofit2.Response; 
import retrofit2.Retrofit; 
import retrofit2.converter.gson.GsonConverterFactory; 


public class MainActivity extends AppCompatActivity { 
    ImageView imageView; 
    TextView temp, city; 
    private static final String TAG = "MainActivity"; 
    private Gson gson = new GsonBuilder().create(); 
    private final String URL = "https://api.worldweatheronline.com";//"https://api.weather.yandex.ru"; 
     private final String KEY ="7083447eff684db4b3892959170401"; 
    private Retrofit retrofit = new Retrofit.Builder() 
      .addConverterFactory(GsonConverterFactory.create(gson)) 
      .baseUrl(URL) 
      .build(); 
    private Link intf = retrofit.create(Link.class); 
    @Override 
    protected void onCreate(final Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     Map<String,String> mapJson = new HashMap<>(); 
     mapJson.put("key",KEY); 
     mapJson.put("q","Kirovohrad"); 
     mapJson.put("num_of_days", "2"); 
     mapJson.put("date","today"); 
     mapJson.put("format","json"); 
     mapJson.put("show_comments","yes"); 
     mapJson.put("showlocaltime","yes"); 
     mapJson.put("lang","ru"); 
     //mapJson.put("lat","48.518804"); 
     //mapJson.put("lon","32.215663"); 
     // mapJson.put("geoid","2"); 
     // mapJson.put("lang", "ru_RU"); 

     final Call<Object> call = intf.weather(mapJson); 
     AsyncTask<Void, Void, Void> execute = new AsyncTask<Void, Void, Void>() { 
      @Override 
      protected Void doInBackground(Void... params) { 

       try { 
        Response<Object> response = call.execute(); 
        Map map= gson.fromJson(String.valueOf(response.body()),Map.class); in this place I have exception 
        Log.d(TAG, String.valueOf(map.get("windspeedKmph"))); 
        // for (Map.Entry e : map.entrySet()) { 
         // System.out.println(e.getKey() + " " + e.getValue()); 
        //} 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
       return null; 
      } 
     }.execute(); 
    } 
} 

This interface Link: 
import java.util.Map; 
import retrofit2.Call; 
import retrofit2.http.GET; 
import retrofit2.http.QueryMap; 

interface Link { 

    @GET("/premium/v1/weather.ashx") 
    Call<Object> weather (@QueryMap Map<String, String> map); 

} 

私はこの例外を持っている:

FATAL EXCEPTION: AsyncTask #1 
                     Process: com.vkramarenko.pogoda, PID: 23674 
                     java.lang.RuntimeException: An error occurred while executing doInBackground() 
                      at android.os.AsyncTask$3.done(AsyncTask.java:309) 
                      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) 
                      at java.util.concurrent.FutureTask.setException(FutureTask.java:223) 
                      at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                      at java.lang.Thread.run(Thread.java:818) 
                     Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 55 path $..request[0].Ukraine 
                      at com.google.gson.Gson.fromJson(Gson.java:902) 
                      at com.google.gson.Gson.fromJson(Gson.java:852) 
                      at com.google.gson.Gson.fromJson(Gson.java:801) 
                      at com.google.gson.Gson.fromJson(Gson.java:773) 
                      at com.vkramarenko.pogoda.MainActivity$1.doInBackground(MainActivity.java:61) 
                      at com.vkramarenko.pogoda.MainActivity$1.doInBackground(MainActivity.java:55) 
                      at android.os.AsyncTask$2.call(AsyncTask.java:295) 
                      at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  
                      at java.lang.Thread.run(Thread.java:818)  
                     Caused by: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 55 path $..request[0].Ukraine 
                      at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559) 
                      at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:530) 
                      at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) 
                      at com.google.gson.internal.bind.ObjectTypeAdapter.read(ObjectTypeAdapter.java:55) 
                      at com.google.gson.internal.bind.ObjectTypeAdapter.read(ObjectTypeAdapter.java:70) 
                      at com.google.gson.internal.bind.ObjectTypeAdapter.read(ObjectTypeAdapter.java:61) 
                      at com.google.gson.internal.bind.ObjectTypeAdapter.read(ObjectTypeAdapter.java:70) 
                      at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) 
                      at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:187) 
                      at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145) 
                      at com.google.gson.Gson.fromJson(Gson.java:887) 

は、その世界の天気オンライン・リターンがJSONされています

{"data":{"request":[{"type":"City","query":"Kirovohrad, Ukraine"}],"time_zone":[{"localtime":"2017-01-04 14:46","utcOffset":"2.0"}],"current_condition":[{"observation_time":"12:46 PM","temp_C":"-3","temp_F":"27","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"windspeedMiles":"19","windspeedKmph":"31","winddirDegree":"207","winddir16Point":"SSW","precipMM":"0.0","humidity":"76","visibility":"10","pressure":"1010","cloudcover":"54","FeelsLikeC":"-10","FeelsLikeF":"14"}],"weather":[{"date":"2017-01-04","astronomy":[{"sunrise":"07:43 AM","sunset":"04:09 PM","moonrise":"10:58 AM","moonset":"11:00 PM"}],"maxtempC":"-1","maxtempF":"30","mintempC":"-5","mintempF":"24","uvIndex":"1","hourly":[{"time":"0","tempC":"-6","tempF":"21","windspeedMiles":"10","windspeedKmph":"17","winddirDegree":"255","winddir16Point":"WSW","weatherCode":"113","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png"}],"weatherDesc":[{"value":"Clear"}],"lang_ru":[{"value":"Ясно"}],"precipMM":"0.0","humidity":"94","visibility":"10","pressure":"1016","cloudcover":"63","HeatIndexC":"-6","HeatIndexF":"21","DewPointC":"-7","DewPointF":"19","WindChillC":"-12","WindChillF":"10","WindGustMiles":"20","WindGustKmph":"32","FeelsLikeC":"-12","FeelsLikeF":"10","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"95","chanceoffrost":"99","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"300","tempC":"-7","tempF":"20","windspeedMiles":"11","windspeedKmph":"17","winddirDegree":"239","winddir16Point":"WSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"93","visibility":"10","pressure":"1015","cloudcover":"34","HeatIndexC":"-7","HeatIndexF":"20","DewPointC":"-7","DewPointF":"19","WindChillC":"-13","WindChillF":"9","WindGustMiles":"20","WindGustKmph":"33","FeelsLikeC":"-13","FeelsLikeF":"9","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"75","chanceoffrost":"99","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"600","tempC":"-6","tempF":"21","windspeedMiles":"13","windspeedKmph":"20","winddirDegree":"221","winddir16Point":"SW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"89","visibility":"10","pressure":"1013","cloudcover":"49","HeatIndexC":"-6","HeatIndexF":"21","DewPointC":"-8","DewPointF":"18","WindChillC":"-13","WindChillF":"9","WindGustMiles":"24","WindGustKmph":"38","FeelsLikeC":"-13","FeelsLikeF":"9","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"44","chanceoffrost":"99","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"900","tempC":"-5","tempF":"24","windspeedMiles":"17","windspeedKmph":"27","winddirDegree":"211","winddir16Point":"SSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"82","visibility":"10","pressure":"1011","cloudcover":"37","HeatIndexC":"-5","HeatIndexF":"24","DewPointC":"-7","DewPointF":"19","WindChillC":"-12","WindChillF":"10","WindGustMiles":"28","WindGustKmph":"45","FeelsLikeC":"-12","FeelsLikeF":"10","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"85","chanceoffrost":"98","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1200","tempC":"-2","tempF":"28","windspeedMiles":"19","windspeedKmph":"31","winddirDegree":"206","winddir16Point":"SSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"75","visibility":"10","pressure":"1009","cloudcover":"46","HeatIndexC":"-2","HeatIndexF":"28","DewPointC":"-6","DewPointF":"21","WindChillC":"-10","WindChillF":"15","WindGustMiles":"28","WindGustKmph":"46","FeelsLikeC":"-10","FeelsLikeF":"15","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"93","chanceoffrost":"97","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1500","tempC":"-1","tempF":"30","windspeedMiles":"19","windspeedKmph":"30","winddirDegree":"206","winddir16Point":"SSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"76","visibility":"10","pressure":"1006","cloudcover":"35","HeatIndexC":"-1","HeatIndexF":"30","DewPointC":"-5","DewPointF":"23","WindChillC":"-8","WindChillF":"17","WindGustMiles":"29","WindGustKmph":"47","FeelsLikeC":"-8","FeelsLikeF":"17","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"97","chanceoffrost":"98","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1800","tempC":"-2","tempF":"29","windspeedMiles":"17","windspeedKmph":"27","winddirDegree":"211","winddir16Point":"SSW","weatherCode":"119","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Cloudy"}],"lang_ru":[{"value":"Облачно"}],"precipMM":"0.0","humidity":"81","visibility":"10","pressure":"1005","cloudcover":"58","HeatIndexC":"-2","HeatIndexF":"29","DewPointC":"-5","DewPointF":"24","WindChillC":"-8","WindChillF":"17","WindGustMiles":"28","WindGustKmph":"45","FeelsLikeC":"-8","FeelsLikeF":"17","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"61","chanceoffrost":"95","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"2100","tempC":"-2","tempF":"28","windspeedMiles":"15","windspeedKmph":"24","winddirDegree":"215","winddir16Point":"SW","weatherCode":"332","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0036_cloudy_with_heavy_snow_night.png"}],"weatherDesc":[{"value":"Moderate snow"}],"lang_ru":[{"value":"Умеренный снег"}],"precipMM":"0.0","humidity":"86","visibility":"8","pressure":"1004","cloudcover":"88","HeatIndexC":"-2","HeatIndexF":"28","DewPointC":"-4","DewPointF":"24","WindChillC":"-9","WindChillF":"17","WindGustMiles":"25","WindGustKmph":"41","FeelsLikeC":"-9","FeelsLikeF":"17","chanceofrain":"4","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"0","chanceoffrost":"97","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"4","chanceofthunder":"0"}]},{"date":"2017-01-05","astronomy":[{"sunrise":"07:43 AM","sunset":"04:10 PM","moonrise":"11:27 AM","moonset":"No moonset"}],"maxtempC":"0","maxtempF":"33","mintempC":"-7","mintempF":"20","uvIndex":"1","hourly":[{"time":"0","tempC":"-3","tempF":"27","windspeedMiles":"13","windspeedKmph":"21","winddirDegree":"214","winddir16Point":"SW","weatherCode":"323","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0027_light_snow_showers_night.png"}],"weatherDesc":[{"value":"Patchy light snow"}],"lang_ru":[{"value":"Местами небольшой снег"}],"precipMM":"0.1","humidity":"89","visibility":"7","pressure":"1003","cloudcover":"83","HeatIndexC":"-3","HeatIndexF":"27","DewPointC":"-4","DewPointF":"25","WindChillC":"-9","WindChillF":"17","WindGustMiles":"21","WindGustKmph":"34","FeelsLikeC":"-9","FeelsLikeF":"17","chanceofrain":"7","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"0","chanceoffrost":"94","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"7","chanceofthunder":"0"},{"time":"300","tempC":"-4","tempF":"25","windspeedMiles":"11","windspeedKmph":"18","winddirDegree":"214","winddir16Point":"SSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.1","humidity":"90","visibility":"10","pressure":"1003","cloudcover":"49","HeatIndexC":"-4","HeatIndexF":"25","DewPointC":"-5","DewPointF":"23","WindChillC":"-10","WindChillF":"15","WindGustMiles":"20","WindGustKmph":"33","FeelsLikeC":"-10","FeelsLikeF":"15","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"1","chanceoffrost":"98","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"600","tempC":"-5","tempF":"24","windspeedMiles":"9","windspeedKmph":"14","winddirDegree":"213","winddir16Point":"SSW","weatherCode":"119","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Cloudy"}],"lang_ru":[{"value":"Облачно"}],"precipMM":"0.0","humidity":"90","visibility":"10","pressure":"1004","cloudcover":"60","HeatIndexC":"-5","HeatIndexF":"24","DewPointC":"-6","DewPointF":"21","WindChillC":"-10","WindChillF":"14","WindGustMiles":"19","WindGustKmph":"30","FeelsLikeC":"-10","FeelsLikeF":"14","chanceofrain":"1","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"1","chanceofsunshine":"1","chanceoffrost":"96","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"1","chanceofthunder":"0"},{"time":"900","tempC":"-3","tempF":"26","windspeedMiles":"8","windspeedKmph":"13","winddirDegree":"214","winddir16Point":"SW","weatherCode":"119","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png"}],"weatherDesc":[{"value":"Cloudy"}],"lang_ru":[{"value":"Облачно"}],"precipMM":"0.0","humidity":"87","visibility":"10","pressure":"1005","cloudcover":"85","HeatIndexC":"-3","HeatIndexF":"26","DewPointC":"-5","DewPointF":"23","WindChillC":"-8","WindChillF":"18","WindGustMiles":"15","WindGustKmph":"25","FeelsLikeC":"-8","FeelsLikeF":"18","chanceofrain":"1","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"2","chanceofsunshine":"33","chanceoffrost":"96","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1200","tempC":"0","tempF":"31","windspeedMiles":"8","windspeedKmph":"13","winddirDegree":"220","winddir16Point":"SW","weatherCode":"113","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png"}],"weatherDesc":[{"value":"Sunny"}],"lang_ru":[{"value":"Солнечно"}],"precipMM":"0.0","humidity":"83","visibility":"10","pressure":"1006","cloudcover":"61","HeatIndexC":"0","HeatIndexF":"31","DewPointC":"-3","DewPointF":"27","WindChillC":"-5","WindChillF":"24","WindGustMiles":"12","WindGustKmph":"19","FeelsLikeC":"-5","FeelsLikeF":"24","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"1","chanceofsunshine":"98","chanceoffrost":"64","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1500","tempC":"-1","tempF":"31","windspeedMiles":"8","windspeedKmph":"12","winddirDegree":"230","winddir16Point":"SW","weatherCode":"113","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png"}],"weatherDesc":[{"value":"Sunny"}],"lang_ru":[{"value":"Солнечно"}],"precipMM":"0.0","humidity":"86","visibility":"10","pressure":"1007","cloudcover":"19","HeatIndexC":"-1","HeatIndexF":"31","DewPointC":"-3","DewPointF":"27","WindChillC":"-5","WindChillF":"24","WindGustMiles":"12","WindGustKmph":"19","FeelsLikeC":"-5","FeelsLikeF":"24","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"97","chanceoffrost":"42","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"1800","tempC":"-3","tempF":"26","windspeedMiles":"8","windspeedKmph":"13","winddirDegree":"239","winddir16Point":"WSW","weatherCode":"113","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png"}],"weatherDesc":[{"value":"Clear"}],"lang_ru":[{"value":"Ясно"}],"precipMM":"0.0","humidity":"88","visibility":"10","pressure":"1008","cloudcover":"17","HeatIndexC":"-3","HeatIndexF":"26","DewPointC":"-5","DewPointF":"23","WindChillC":"-8","WindChillF":"18","WindGustMiles":"17","WindGustKmph":"28","FeelsLikeC":"-8","FeelsLikeF":"18","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"80","chanceoffrost":"92","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"},{"time":"2100","tempC":"-5","tempF":"23","windspeedMiles":"10","windspeedKmph":"17","winddirDegree":"256","winddir16Point":"WSW","weatherCode":"116","weatherIconUrl":[{"value":"http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0004_black_low_cloud.png"}],"weatherDesc":[{"value":"Partly cloudy"}],"lang_ru":[{"value":"Переменная облачность"}],"precipMM":"0.0","humidity":"89","visibility":"10","pressure":"1011","cloudcover":"14","HeatIndexC":"-5","HeatIndexF":"23","DewPointC":"-6","DewPointF":"20","WindChillC":"-11","WindChillF":"13","WindGustMiles":"20","WindGustKmph":"33","FeelsLikeC":"-11","FeelsLikeF":"13","chanceofrain":"0","chanceofremdry":"0","chanceofwindy":"0","chanceofovercast":"0","chanceofsunshine":"53","chanceoffrost":"97","chanceofhightemp":"0","chanceoffog":"0","chanceofsnow":"0","chanceofthunder":"0"}]}],"ClimateAverages":[{"month":[{"index":"1","name":"January","avgMinTemp":"-6.1","avgMinTemp_F":"21.0","absMaxTemp":"10.4","absMaxTemp_F":"50.7"},{"index":"2","name":"February","avgMinTemp":"-5.7","avgMinTemp_F":"21.7","absMaxTemp":"14.2","absMaxTemp_F":"57.6"},{"index":"3","name":"March","avgMinTemp":"-1.1","avgMinTemp_F":"30.0","absMaxTemp":"19.4","absMaxTemp_F":"66.9"},{"index":"4","name":"April","avgMinTemp":"5.3","avgMinTemp_F":"41.5","absMaxTemp":"25.5","absMaxTemp_F":"77.9"},{"index":"5","name":"May","avgMinTemp":"11.1","avgMinTemp_F":"52.0","absMaxTemp":"35.7","absMaxTemp_F":"96.3"},{"index":"6","name":"June","avgMinTemp":"15.4","avgMinTemp_F":"59.7","absMaxTemp":"35.4","absMaxTemp_F":"95.7"},{"index":"7","name":"July","avgMinTemp":"17.6","avgMinTemp_F":"63.7","absMaxTemp":"38.4","absMaxTemp_F":"101.1"},{"index":"8","name":"August","avgMinTemp":"16.4","avgMinTemp_F":"61.5","absMaxTemp":"36.5","absMaxTemp_F":"97.7"},{"index":"9","name":"September","avgMinTemp":"10.9","avgMinTemp_F":"51.6","absMaxTemp":"32.1","absMaxTemp_F":"89.8"},{"index":"10","name":"October","avgMinTemp":"5.7","avgMinTemp_F":"42.3","absMaxTemp":"28.5","absMaxTemp_F":"83.3"},{"index":"11","name":"November","avgMinTemp":"0.6","avgMinTemp_F":"33.1","absMaxTemp":"18.6","absMaxTemp_F":"65.5"},{"index":"12","name":"December","avgMinTemp":"-4.2","avgMinTemp_F":"24.4","absMaxTemp":"16.5","absMaxTemp_F":"61.7"}]}]}} 
+0

1行52文字は「クエリ」の後の '、'です:「Kirovoh rad –

答えて

0

これは私が

Weather weather = new Weather(); //This is just a class that has a bunch of strings in it for the weather info. 
     JSONObject jObj = new JSONObject(data); 

     //Parsing JSON data 
     JSONObject dObj = jObj.getJSONObject("data"); 
     JSONArray cArr = dObj.getJSONArray("current_condition"); 
     JSONObject JSONCurrent = cArr.getJSONObject(0); 
     weather.setCurrent_temp(getString("temp_F",JSONCurrent)); 
     weather.setHour(getString("observation_time",JSONCurrent)); 
     JSONArray jArr = dObj.getJSONArray("weather"); 
     JSONObject JSONWeather = jArr.getJSONObject(0); 
     JSONArray jArrIcon = JSONWeather.getJSONArray("weatherIconUrl"); 
     JSONObject JSONIcon = jArrIcon.getJSONObject(0); 
     weather.setDate(getString("date",JSONWeather)); 
     weather.setPrecipmm(getString("precipMM",JSONWeather)); 
     weather.setTempMaxc(getString("tempMaxC",JSONWeather)); 
     weather.setTempMaxf(getString("tempMaxF",JSONWeather)); 
     weather.setTempMinf(getString("tempMinF",JSONWeather)); 
     weather.setTempMinc(getString("tempMinC",JSONWeather)); 
     weather.setWeatherCode(getString("weatherCode",JSONWeather)); 
     weather.setWeatherIconURL(getString("value",JSONIcon)); 
     weather.setWinddir16point(getString("winddir16Point",JSONWeather)); 
     weather.setWinddirDegree(getString("winddirDegree",JSONWeather)); 
     weather.setWindspeedKmph(getString("windspeedKmph",JSONWeather)); 
     weather.setWindspeedMiles(getString("windspeedMiles",JSONWeather)); 
をやった方法です
+0

apiからデータ(json)を取得し、マップに変換します –

関連する問題