fastJson解析複雜的json字符串,經測試已經成功解析

要解析的json數據格式爲:java

HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ResponseStatus: 
	{
		
	},
	Data: 
	{
		TourCopyWriterInfo: 
		{
			DefaultCopyWriter: String,
			SearchValue: String
		},
		ThemeList: 
		[
			{
				Key: String,
				Value: String,
				PoiId: String,
				IsJump: False
			}
		],
		DestinationList: 
		[
			{
				DestName: String,
				CategoryId: 0,
				SubDestList: 
				[
					{
						Key: String,
						Value: String,
						PoiId: String,
						IsJump: False
					}
				]
			}
		],
		TourProductList: 
		{
			
		}
	}
}

要解析的爲Data對象中的ThemeList數組,本身寫的ThemeList元素的javabean代碼以下:
/**
* Created by sqhan on 2016/5/30.
*/
public class TopTripType {
String key;
String value;
String poiId;
boolean isJump;

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getValue() {
return value;
}

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

public String getPoiId() {
return poiId;
}

public void setPoiId(String poiId) {
this.poiId = poiId;
}

public boolean isJump() {
return isJump;
}

public void setJump(boolean jump) {
isJump = jump;
}
}

解析的代碼爲:
//用fastjson來解析拉取到的數據,經測試已解析成功
    public List<TopTripType> parseResponseData(String responseStr) {
        List<TopTripType> result;
        try {
            JSONObject object = JSON.parseObject(responseStr);
            JSONObject data = (JSONObject) object.get("Data");
            JSONArray jsonArray = data.getJSONArray("ThemeList");
            result = JSON.parseArray(jsonArray.toJSONString(), TopTripType.class);

        } catch (Exception e) {
            result = new ArrayList<>();
            LogUtil.e(TAG, "parseResponseData()中解析json出現異常");
        }
        return result;

    } 

 

另外發現一個超級好用的百度雲盤下載加速器(實測全速下載)

下載地址

下載地址1:http://t.cn/E773Z7ujson

下載地址2:http://t.cn/E77m67zwindows

 

 

該工具爲永久破解版,免安裝,支持windows系統,直接點擊運行,而後便可體驗飛的下載速度。數組

不再用怕百度網盤的限速了,下載速度zei爽,喜歡的老鐵拿去!!!工具

 

 

 

OK,有些細節再也不詳細說明,須要請留言多多交流。post

相關文章
相關標籤/搜索