可获得一段json数据,解析后如下:
{
"weatherinfo":{
"city":"北京",
"city_en":"beijing",
"date_y":"2013年10月24日",
"date":"",
"week":"星期四",
"fchh":"11",
"cityid":"101010100",
//摄氏温度
"temp1":"16℃~4℃",
"temp2":"18℃~3℃",
"temp3":"18℃~6℃",
"temp4":"17℃~8℃",
"temp5":"17℃~7℃",
"temp6":"16℃~5℃",
//华氏温度
"tempF1":"60.8℉~39.2℉",
"tempF2":"64.4℉~37.4℉",
"tempF3":"64.4℉~42.8℉",
"tempF4":"62.6℉~46.4℉",
"tempF5":"62.6℉~44.6℉",
"tempF6":"60.8℉~41℉",
//天气描述
"weather1":"晴",
"weather2":"晴",
"weather3":"晴转多云",
"weather4":"多云转阴",
"weather5":"阵雨转多云",
"weather6":"多云转晴",
//天气描述图片序号
"img1":"0",
"img2":"99",
"img3":"0",
"img4":"99",
"img5":"0",
"img6":"1",
"img7":"1",
"img8":"2",
"img9":"3",
"img10":"1",
"img11":"1",
"img12":"0",
"img_single":"0",
//图片名称
"img_title1":"晴",
"img_title2":"晴",
"img_title3":"晴",
"img_title4":"晴",
"img_title5":"晴",
"img_title6":"多云",
"img_title7":"多云",
"img_title8":"阴",
"img_title9":"阵雨",
"img_title10":"多云",
"img_title11":"多云",
"img_title12":"晴",
"img_title_single":"晴",
//风速描述
"wind1":"北风3-4级转微风",
"wind2":"微风",
"wind3":"微风",
"wind4":"微风",
"wind5":"微风",
"wind6":"微风",
//风速级别描述
"fx1":"北风",
"fx2":"微风",
"fl1":"3-4级转小于3级",
"fl2":"小于3级",
"fl3":"小于3级",
"fl4":"小于3级",
"fl5":"小于3级",
"fl6":"小于3级",
//今天穿衣指数
"index":"冷",
"index_d":"天气冷,建议着棉服、羽绒服、皮夹克加羊毛衫等冬季服装。年老体弱者宜着厚棉衣、冬大衣或厚羽绒服。",
//48小时穿衣指数
"index48":"较冷",
"index48_d":"建议着大衣、呢外套加毛衣、卫衣等服装。体弱者宜着厚外套、厚毛衣。因昼夜温差较大,注意增减衣服。",
//紫外线及48小时紫外线
"index_uv":"中等",
"index48_uv":"中等",
/洗车
"index_xc":"适宜",
//旅游
"index_tr":"适宜",
//舒适指数
"index_co":"舒适",
"st1":"14",
"st2":"4",
"st3":"17",
"st4":"3",
"st5":"17",
"st6":"6",
//晨练
"index_cl":"较适宜",
//晾晒
"index_ls":"适宜",
//过敏
"index_ag":"不易发"
}
}
提取其中的天气描述、天气描述图片序号、图片名称:
//天气描述
"weather1":"晴",
"weather2":"晴",
"weather3":"晴转多云",
"weather4":"多云转阴",
"weather5":"阵雨转多云",
"weather6":"多云转晴",
//天气描述图片序号
"img1":"0",
"img2":"99",
"img3":"0",
"img4":"99",
"img5":"0",
"img6":"1",
"img7":"1",
"img8":"2",
"img9":"3",
"img10":"1",
"img11":"1",
"img12":"0",
"img_single":"0",
//图片名称
"img_title1":"晴",
"img_title2":"晴",
"img_title3":"晴",
"img_title4":"晴",
"img_title5":"晴",
"img_title6":"多云",
"img_title7":"多云",
"img_title8":"阴",
"img_title9":"阵雨",
"img_title10":"多云",
"img_title11":"多云",
"img_title12":"晴",
"img_title_single":"晴",
发现6天的天气对比的图片序号和名称均为12个,观察得出,每一天的天气对应两张图片
"weather1":"晴",对应的图片序号为
- "img1":"0",
- "img2":"99",
图片名称为
- "img_title1":"晴",
- "img_title2":"晴",
"weather4":"多云转阴",对应的图片序号为
img7":"1",
img8":"2",
对应的图片名称为:
- "img_title7":"多云",
- "img_title8":"阴",
不对!99是哪里来的?当"weather1":"晴"时,对应的图片序号为
- "img1":"0",
- "img2":"99",
按道理说,这里是两个晴,图片序号应该是 "img1":"0", "img2":"0"
原来,当图片名称重复时,第二个图片序号就会是99。