Weather forecast App (1)

Source: Internet
Author: User

Before the implementation of the list can be listed in all the provinces, cities, counties, and then query the country any city's weather information. Query weather information using the API with wind weather, the weather information obtained by this API is in JOSN format.

The first step in parsing josn data using the Gson library is to create the corresponding object first.

I made a few cuts to the official example, and then I could see the information I wanted to show in this project this time:

{    "HeWeather5 ": [        {            "AQI ": {                "City ": {                    "AQI ":",                    "pm25 ":",                }            },             "Basic ": {                "City ":" Qinhuangdao ",                "ID ":" CN101091101 ",                "Update ": {                    "Loc ":" 2017-09-10 14:46 ",                }            },             "daily_forecast ": [                {                    "cond ": {                        "txt_d ":" Light Rain ",                    },                     "Date ":" 2017-09-10 ",                    "tmp ": {                        "Max ":",                        "min ":"                    },                 },                 {                                        "cond ": {                        "txt_d ":" Clear ",                    },                     "Date ":" 2017-09-11 ",                    "tmp ": {                        "Max ":",                        "min ":"                    },                },                 {                    "cond ": {                        "txt_d ":" Clear ",                    },                     "Date ":" 2017-09-12 ",                    "tmp ": {                        "Max ":",                        "min ":"                    },                 }            ],             "status ": Ok",            "suggestion ": {                "Comf ": {                    "BRF ":" More comfortable ",                    "txt ":" Rain during the day, so that the air humidity increases, will make people feel a little stuffy, but the morning and evening the weather is very cool, comfortable. "                },                 "cw ": {                    "BRF ":" Not appropriate ",                    "txt ":" should not wash the car, rain in the next 24 hours, if during this period of washing car, rain and muddy water may be dirty your car again. "                },                                 "Sport ": {                    "BRF ":" Less appropriate ",                    "txt ":" There is precipitation, it is recommended that you indoor fitness and leisure activities, if you insist on outdoor sports, should pay attention to carry rain gear and pay attention to the rain and anti-skid. "                },             }        }    ]}
Weather Information Total

Which weather conditions AQI:

{      "aqi": {"city    ":        {"        " "                 }            }
}      

The established AQI object code is:

 Public class AQI {    public  aqicity city;      Public class aqicity{        public  String aqi;          Public String pm25;}    }

The point here is that "{}" includes an object to be illuminated with an object.

Then the information of the city basic:

{       "Basic": {                 "" "          Update ": {             "                   }                  

Weather forecast App (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.