最近弄了一个wifi获取天气的程序,使用cjson解析墨迹天气返回的json程序,但是使用 cJSON_Parse()函数将文本转成JSON结构时总是返回空,不知道哪里原因,有遇到过的朋友可以帮忙看看。
获取到的未来6天天气数据
{"code":0,"data":{"city":{"cityId":284975,"counname":"涓浗","ianatimezone":"Asia\/Shanghai","name":"鍘嗗煄鍖?","pname":"灞变笢鐪?","secondaryname":"娴庡崡甯?","timezone":"8"},"forecast":[{"conditionDay":"灏忛洦","conditionIdDay":"7","conditionIdNight":"7","conditionNight":"灏忛洦","humidity":"56","pop":"60","predictDate":"2020-04-08","qpf":"0.7","tempDay":"18","tempNight":"7","updatetime":"2020-04-08 20:07:00","uvi":"4","windDegreesDay":"135","windDegreesNight":"135","windDirDay":"涓滃崡椋?","windDirNight":"涓滃崡椋?","windLevelDay":"3-4","windLevelNight":"3-4"},{"conditionDay":"涓洦","conditionIdDay":"8","conditionIdNight":"7","conditionNight":"灏忛洦","humidity":"72","pop":"80","predictDate":"2020-04-09","qpf":"11.7","tempDay":"11","tempNight":"5","updatetime":"2020-04-08 20:07:00","uvi":"1","windDegreesDay":"45","windDegreesNight":"45","windDirDay":"涓滃寳椋?","windDirNight":"涓滃寳椋?","windLevelDay":"4-5","windLevelNight":"3-4"},{"conditionDay":"闃?","conditionIdDay":"2","conditionIdNight":"31","conditionNight":"澶氫簯","humidity":"67","pop":"60","predictDate":"2020-04-10","qpf":"3.1","tempDay":"13","tempNight":"6","updatetime":"2020-04-08 20:07:00","uvi":"1","windDegreesDay":"45","windDegreesNight":"0","windDirDay":"涓滃寳椋?","windDirNight":"鍖楅","windLevelDay":"3-4","windLevelNight":"3-4"},{"conditionDay":"澶氫簯","conditionIdDay":"1","conditionIdNight":"31","conditionNight":"澶氫簯","humidity":"40","pop":"20","predictDate":"2020-04-11","qpf":"0.0","tempDay":"16","tempNight":"7","updatetime":"2020-04-08 20:07:00","uvi":"9","windDegreesDay":"0","windDegreesNight":"0","windDirDay":"鍖楅","windDirNight":"鍖楅","windLevelDay":"3-4","windLevelNight":"3"},{"conditionDay":"鏅?","conditionIdDay":"0","conditionIdNight":"30","conditionNight":"鏅?","humidity":"30","pop":"20","predictDate":"2020-04-12","qpf":"0.0","tempDay":"19","tempNight":"7","updatetime":"2020-04-08 20:07:00","uvi":"9","windDegreesDay":"0","windDegreesNight":"180","windDirDay":"鍖楅","windDirNight":"鍗楅","windLevelDay":"3-4","windLevelNight":"3"},{"conditionDay":"鏅?","conditionIdDay":"0","conditionIdNight":"30","conditionNight":"鏅?","humidity":"25","pop":"20","predictDate":"2020-04-13","qpf":"0.0","tempDay":"22","tempNight":"11","updatetime":"2020-04-08 20:07:00","uvi":"11","windDegreesDay":"180","windDegreesNight":"180","windDirDay":"鍗楅","windDirNight":"鍗楅","windLevelDay":"3-4","windLevelNight":"4-5"}]},"msg":"success","rc":{"c":0,"p":"success"}}
已经验证这些文本数据转成JSON是对的,但是使用cJSON_Parse()就返回空。校验结果如下:
|