Json解析tool工具
2020-12-09 08:58
标签:style blog java color io 2014 JsonTools json对象在花括号中 Json解析tool工具,搜素材,soscw.com Json解析tool工具 标签:style blog java color io 2014 原文地址:http://blog.csdn.net/u010794950/article/details/24650421package com.example.weather_json.tools;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.example.weather_json.Entity.Results;
import com.example.weather_json.Entity.WeatherData;
import com.example.weather_json.Entity.WeatherInfo;
public class JsonTools {
public static WeatherInfo MyGetJSON(String jsonString) throws JSONException {
List
{
"error": 0,
"status": "success",
"date": "2014-04-28",
"results": [
{
"currentCity": "合肥",
"weather_data": [
{
"date": "周一(今天, 实时:22℃)",
"dayPictureUrl": "www.baidu.com",
"nightPictureUrl": "www.baidu.com",
"weather": "多云转晴",
"wind": "西北风微风",
"temperature": "22 ~ 13℃"
},
{
"date": "周二",
"dayPictureUrl": "www.baidu.com",
"nightPictureUrl": "1www.baidu.com",
"weather": "多云",
"wind": "西北风微风",
"temperature": "24 ~ 14℃"
},
{
"date": "周三",
"dayPictureUrl": "www.baidu.com",
"nightPictureUrl": "www.baidu.com",
"weather": "多云转晴",
"wind": "南风微风",
"temperature": "26 ~ 14℃"
},
{
"date": "周四",
"dayPictureUrl": "www.baidu.com",
"nightPictureUrl": "www.baidu.com",
"weather": "晴",
"wind": "东南风微风",
"temperature": "27 ~ 13℃"
}
]
}
]
}
{ "firstName":"John" , "lastName":"Doe" }
json数组在中括号中
{
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
在上面的例子中,对象 "employees" 是包含三个对象的数组。每个对象代表一条关于某人(有姓和名)的记录。