zoukankan      html  css  js  c++  java
  • fastJson解析复杂的json字符串,经测试已经成功解析

    要解析的json数据格式为:

    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/E773Z7u

    下载地址2:http://t.cn/E77m67z

    该工具为永久破解版,免安装,支持windows系统,直接点击运行,然后即可体验飞的下载速度。

    再也不用怕百度网盘的限速了,下载速度zei爽,喜欢的老铁拿去!!!

     

    OK,有些细节不再详细说明,需要请留言多多交流。



  • 相关阅读:
    .NET XmlNavigator with Namespace
    编程要素
    【FOJ】1962 新击鼓传花游戏
    【POJ】1389 Area of Simple Polygons
    【POJ】2482 Stars in Your Window
    【HDU】3265 Posters
    【HDU】1199 Color the Ball
    【HDU】3642 Get The Treasury
    【HDU】4027 Can you answer these queries?
    【HDU】1542 Atlantis
  • 原文地址:https://www.cnblogs.com/hsqdboke/p/5545183.html
Copyright © 2011-2022 走看看