获取Null Pointer Exception以使用Gson解析Json数据

时间:2015-11-14 07:54:30

标签: java android json gson

我只是使用Gson解析json数据。但是它给出了NullPointerException 这是我的json文件JSON File

这是我的CustomAdapter,它处理操作并将数据添加到listview MyCustomAdapter

package com.vap.gsonexample;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Virat Puar on 14-11-2015.
 */
public class CustomAdapter extends BaseAdapter {
    private List<Response.DataEntity> weatheritem;
    private Context mcontext;
    private LayoutInflater inflater;

    public CustomAdapter(Context mcontext, List<Response.DataEntity> weatheritem) {
        this.mcontext = mcontext;
        this.weatheritem = weatheritem;
    }

    @Override
    public int getCount() {
        return weatheritem.size();
    }

    @Override
    public Object getItem(int position) {
        return weatheritem.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        inflater = (LayoutInflater)mcontext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view =inflater.inflate(R.layout.each_item,parent,false);
        Response.DataEntity dataEntity = (Response.DataEntity) getItem(position);
        ImageView thumbnial = (ImageView) view.findViewById(R.id.thumbnial);
        TextView date = (TextView) view.findViewById(R.id.date);
        TextView weathercode = (TextView) view.findViewById(R.id.weathercode);
        String imageUrl = dataEntity.getWeather().get(position).getWeatherIconUrl().get(position).getValue();
        date.setText(dataEntity.getWeather().get(position).getDate());
        weathercode.setText(dataEntity.getWeather().get(position).getWeatherCode());
        Picasso.with(mcontext).load(imageUrl).into(thumbnial);
        return view;
    }
}

这是我的主要活动代码,其中发生错误MainActivity

package com.vap.gsonexample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;

import java.lang.reflect.Type;
import java.util.List;

import cz.msebera.android.httpclient.Header;

public class MainActivity extends AppCompatActivity {
    Response response;
    CustomAdapter customAdapter;
    String url ="http://api.worldweatheronline.com/free/v1/weather.ashx?" +
            "q=Rajkot&format=json&num_of_days=5&key=xz9js2zhayhj4bcxuf7br2bg";
    Gson gson;
    AsyncHttpClient client;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final ListView listView = (ListView) findViewById(R.id.listView);
        client = new AsyncHttpClient();
        client.get(MainActivity.this,url, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                String responsestr = new String(responseBody);
                Type listtype = new TypeToken<Response>(){}.getType();
                Response response = gson.fromJson(responsestr, listtype);
                customAdapter = new CustomAdapter(MainActivity.this, (List<Response.DataEntity>) response.getData());
                listView.setAdapter(customAdapter);
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                Toast.makeText(getApplication(),"Fail"+statusCode+error,Toast.LENGTH_LONG).show();
            }
        });
    }
}

最后这是我的日志文件

    E/AndroidRuntime: FATAL EXCEPTION: main
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime: java.lang.RuntimeException: java.lang.ClassCastException: com.vap.gsonexample.Response$DataEntity cannot be cast to java.util.List
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.onUserException(AsyncHttpResponseHandler.java:304)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:395)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:  Caused by: java.lang.ClassCastException: com.vap.gsonexample.Response$DataEntity cannot be cast to java.util.List
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.vap.gsonexample.MainActivity$1.onSuccess(MainActivity.java:40)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:351)
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4745) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
11-14 07:25:32.366 1412-1412/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
11-14 07:25:32.394 119-173/? E/SocketStream: readFully was waiting for 403440 bytes, got 16192 
11-14 07:25:32.394 119-173/? E/SocketStream: readFully was waiting for 387248 bytes, got 16192 
11-14 07:25:32.394 119-173/? E/SocketStream: readFully was waiting for 371056 bytes, got 16192 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 354864 bytes, got 15664 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 339200 bytes, got 16192 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 323008 bytes, got 16192 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 306816 bytes, got 16192 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 290624 bytes, got 16192 
11-14 07:25:32.398 119-173/? E/SocketStream: readFully was waiting for 274432 bytes, got 8232 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 266200 bytes, got 16192 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 250008 bytes, got 16192 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 233816 bytes, got 16192 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 217624 bytes, got 16192 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 201432 bytes, got 8232 
11-14 07:25:32.402 119-173/? E/SocketStream: readFully was waiting for 193200 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 177008 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 160816 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 144624 bytes, got 15664 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 128960 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 112768 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 96576 bytes, got 16192 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 80384 bytes, got 15664 
11-14 07:25:32.406 119-173/? E/SocketStream: readFully was waiting for 64720 bytes, got 16192 
11-14 07:25:32.410 119-173/? E/SocketStream: readFully was waiting for 48528 bytes, got 16192 
11-14 07:25:32.410 119-173/? E/SocketStream: readFully was waiting for 32336 bytes, got 16192 
11-14 07:33:23.734 119-173/? E/SocketStream: readFully was waiting for 403440 bytes, got 16192 
11-14 07:33:23.734 119-173/? E/SocketStream: readFully was waiting for 387248 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 371056 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 354864 bytes, got 15664 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 339200 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 323008 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 306816 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 290624 bytes, got 16192 
11-14 07:33:23.738 119-173/? E/SocketStream: readFully was waiting for 274432 bytes, got 8232 
11-14 07:33:23.742 119-173/? E/SocketStream: readFully was waiting for 266200 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 250008 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 233816 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 217624 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 201432 bytes, got 8232 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 193200 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 177008 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 160816 bytes, got 16192 
11-14 07:33:23.746 119-173/? E/SocketStream: readFully was waiting for 144624 bytes, got 16192 
11-14 07:33:23.750 119-173/? E/SocketStream: readFully was waiting for 128432 bytes, got 8232 
11-14 07:33:23.750 119-173/? E/SocketStream: readFully was waiting for 120200 bytes, got 16192 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 104008 bytes, got 16192 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 87816 bytes, got 16192 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 71624 bytes, got 16192 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 55432 bytes, got 8232 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 47200 bytes, got 16192 
11-14 07:33:23.754 119-173/? E/SocketStream: readFully was waiting for 31008 bytes, got 16192 
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH: User-space exception detected!
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH: java.lang.NullPointerException
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at com.vap.gsonexample.MainActivity$1.onSuccess(MainActivity.java:36)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:351)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at android.os.Looper.loop(Looper.java:137)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at java.lang.reflect.Method.invokeNative(Native Method)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at java.lang.reflect.Method.invoke(Method.java:511)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-14 07:33:26.842 1489-1489/? E/AsyncHttpRH:     at dalvik.system.NativeStart.main(Native Method)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime: FATAL EXCEPTION: main
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime: java.lang.RuntimeException: java.lang.NullPointerException
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.onUserException(AsyncHttpResponseHandler.java:304)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:395)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:  Caused by: java.lang.NullPointerException
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.vap.gsonexample.MainActivity$1.onSuccess(MainActivity.java:36)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:351)
11-14 07:33:26.846 1489-1489/? E/AndroidRuntime:     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:510) 

请帮助别人找到此错误。 这是我的响应模型

package com.vap.gsonexample;

import java.util.List;

/**
 * Created by Virat Puar on 14-11-2015.
 */
public class Response {

    private DataEntity data;

    public void setData(DataEntity data) {
        this.data = data;
    }

    public DataEntity getData() {
        return data;
    }

    public class DataEntity {

        private List<RequestEntity> request;
        private List<Current_conditionEntity> current_condition;
        private List<WeatherEntity> weather;

        public void setRequest(List<RequestEntity> request) {
            this.request = request;
        }

        public void setCurrent_condition(List<Current_conditionEntity> current_condition) {
            this.current_condition = current_condition;
        }

        public void setWeather(List<WeatherEntity> weather) {
            this.weather = weather;
        }

        public List<RequestEntity> getRequest() {
            return request;
        }

        public List<Current_conditionEntity> getCurrent_condition() {
            return current_condition;
        }

        public List<WeatherEntity> getWeather() {
            return weather;
        }

        public class RequestEntity {
            /**
             * query : Rajkot, India
             * type : City
             */
            private String query;
            private String type;

            public void setQuery(String query) {
                this.query = query;
            }

            public void setType(String type) {
                this.type = type;
            }

            public String getQuery() {
                return query;
            }

            public String getType() {
                return type;
            }
        }

        public class Current_conditionEntity {
            private String precipMM;
            private String observation_time;
            private List<WeatherDescEntity> weatherDesc;
            private String visibility;
            private String weatherCode;
            private String pressure;
            private String temp_C;
            private String cloudcover;
            private String temp_F;
            private String winddirDegree;
            private String windspeedMiles;
            private String windspeedKmph;
            private String humidity;
            private String winddir16Point;
            private List<WeatherIconUrlEntity> weatherIconUrl;

            public void setPrecipMM(String precipMM) {
                this.precipMM = precipMM;
            }

            public void setObservation_time(String observation_time) {
                this.observation_time = observation_time;
            }

            public void setWeatherDesc(List<WeatherDescEntity> weatherDesc) {
                this.weatherDesc = weatherDesc;
            }

            public void setVisibility(String visibility) {
                this.visibility = visibility;
            }

            public void setWeatherCode(String weatherCode) {
                this.weatherCode = weatherCode;
            }

            public void setPressure(String pressure) {
                this.pressure = pressure;
            }

            public void setTemp_C(String temp_C) {
                this.temp_C = temp_C;
            }

            public void setCloudcover(String cloudcover) {
                this.cloudcover = cloudcover;
            }

            public void setTemp_F(String temp_F) {
                this.temp_F = temp_F;
            }

            public void setWinddirDegree(String winddirDegree) {
                this.winddirDegree = winddirDegree;
            }

            public void setWindspeedMiles(String windspeedMiles) {
                this.windspeedMiles = windspeedMiles;
            }

            public void setWindspeedKmph(String windspeedKmph) {
                this.windspeedKmph = windspeedKmph;
            }

            public void setHumidity(String humidity) {
                this.humidity = humidity;
            }

            public void setWinddir16Point(String winddir16Point) {
                this.winddir16Point = winddir16Point;
            }

            public void setWeatherIconUrl(List<WeatherIconUrlEntity> weatherIconUrl) {
                this.weatherIconUrl = weatherIconUrl;
            }

            public String getPrecipMM() {
                return precipMM;
            }

            public String getObservation_time() {
                return observation_time;
            }

            public List<WeatherDescEntity> getWeatherDesc() {
                return weatherDesc;
            }

            public String getVisibility() {
                return visibility;
            }

            public String getWeatherCode() {
                return weatherCode;
            }

            public String getPressure() {
                return pressure;
            }

            public String getTemp_C() {
                return temp_C;
            }

            public String getCloudcover() {
                return cloudcover;
            }

            public String getTemp_F() {
                return temp_F;
            }

            public String getWinddirDegree() {
                return winddirDegree;
            }

            public String getWindspeedMiles() {
                return windspeedMiles;
            }

            public String getWindspeedKmph() {
                return windspeedKmph;
            }

            public String getHumidity() {
                return humidity;
            }

            public String getWinddir16Point() {
                return winddir16Point;
            }

            public List<WeatherIconUrlEntity> getWeatherIconUrl() {
                return weatherIconUrl;
            }

            public class WeatherDescEntity {
                /**
                 * value : Sunny
                 */
                private String value;

                public void setValue(String value) {
                    this.value = value;
                }

                public String getValue() {
                    return value;
                }
            }

            public class WeatherIconUrlEntity {
                /**
                 * value : http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png
                 */
                private String value;

                public void setValue(String value) {
                    this.value = value;
                }

                public String getValue() {
                    return value;
                }
            }
        }

        public class WeatherEntity {
            private String date;
            private String precipMM;
            private List<WeatherDescEntity> weatherDesc;
            private String tempMinF;
            private String weatherCode;
            private String tempMinC;
            private String winddirection;
            private String winddirDegree;
            private String windspeedMiles;
            private String windspeedKmph;
            private String tempMaxF;
            private String winddir16Point;
            private List<WeatherIconUrlEntity> weatherIconUrl;
            private String tempMaxC;

            public void setDate(String date) {
                this.date = date;
            }

            public void setPrecipMM(String precipMM) {
                this.precipMM = precipMM;
            }

            public void setWeatherDesc(List<WeatherDescEntity> weatherDesc) {
                this.weatherDesc = weatherDesc;
            }

            public void setTempMinF(String tempMinF) {
                this.tempMinF = tempMinF;
            }

            public void setWeatherCode(String weatherCode) {
                this.weatherCode = weatherCode;
            }

            public void setTempMinC(String tempMinC) {
                this.tempMinC = tempMinC;
            }

            public void setWinddirection(String winddirection) {
                this.winddirection = winddirection;
            }

            public void setWinddirDegree(String winddirDegree) {
                this.winddirDegree = winddirDegree;
            }

            public void setWindspeedMiles(String windspeedMiles) {
                this.windspeedMiles = windspeedMiles;
            }

            public void setWindspeedKmph(String windspeedKmph) {
                this.windspeedKmph = windspeedKmph;
            }

            public void setTempMaxF(String tempMaxF) {
                this.tempMaxF = tempMaxF;
            }

            public void setWinddir16Point(String winddir16Point) {
                this.winddir16Point = winddir16Point;
            }

            public void setWeatherIconUrl(List<WeatherIconUrlEntity> weatherIconUrl) {
                this.weatherIconUrl = weatherIconUrl;
            }

            public void setTempMaxC(String tempMaxC) {
                this.tempMaxC = tempMaxC;
            }

            public String getDate() {
                return date;
            }

            public String getPrecipMM() {
                return precipMM;
            }

            public List<WeatherDescEntity> getWeatherDesc() {
                return weatherDesc;
            }

            public String getTempMinF() {
                return tempMinF;
            }

            public String getWeatherCode() {
                return weatherCode;
            }

            public String getTempMinC() {
                return tempMinC;
            }

            public String getWinddirection() {
                return winddirection;
            }

            public String getWinddirDegree() {
                return winddirDegree;
            }

            public String getWindspeedMiles() {
                return windspeedMiles;
            }

            public String getWindspeedKmph() {
                return windspeedKmph;
            }

            public String getTempMaxF() {
                return tempMaxF;
            }

            public String getWinddir16Point() {
                return winddir16Point;
            }

            public List<WeatherIconUrlEntity> getWeatherIconUrl() {
                return weatherIconUrl;
            }

            public String getTempMaxC() {
                return tempMaxC;
            }

            public class WeatherDescEntity {
                /**
                 * value : Sunny
                 */
                private String value;

                public void setValue(String value) {
                    this.value = value;
                }

                public String getValue() {
                    return value;
                }
            }

            public class WeatherIconUrlEntity {
                /**
                 * value : http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png
                 */
                private String value;

                public void setValue(String value) {
                    this.value = value;
                }

                public String getValue() {
                    return value;
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

Response.getData()DataEntity。您将其投放到List<DataEntity>