Json学习

又遇见一个奇妙问题。。。

现在我要把item里面的内容都取出来,格式如下

 "items": [

 {

  "kind": "customsearch#result",

  "title": "New Orleans: Aaron Neville & the DirtyDozen Brass Band ...",

  "htmlTitle": "\u003cb\u003eNew Orleans\u003c/b\u003e:\u003cb\u003eAaron Neville\u003c/b\u003e & the Dirty Dozen Brass Band\u003cb\u003e...\u003c/b\u003e",

  "link":"http://www.arshtcenter.org/Tickets/Calendar/2013-2014-Season/Jazz-Roots/New-Orleans/",

  "displayLink": "www.arshtcenter.org",

  "snippet": "Aaron Neville and the Dirty Dozen Brass BandNew Orleans' reigning prince of \nR&B and soul, Aaron Neville, and itsworld-famous Dirty Dozen Brass Band will聽...",

  "htmlSnippet": "\u003cb\u003eAaron Neville\u003c/b\u003eand the Dirty Dozen Brass Band \u003cb\u003eNew Orleans\u003c/b\u003e'reigning prince of \u003cbr\u003e\nR&B and soul, \u003cb\u003eAaronNeville\u003c/b\u003e, and its world-famous Dirty Dozen Brass Bandwill ...",

  "cacheId": "kybgXPsosBMJ",

  "formattedUrl": "www.arshtcenter.org/Tickets/Calendar/2013-2014.../New-Orleans/",

  "htmlFormattedUrl":"www.arshtcenter.org/Tickets/Calendar/2013-2014.../\u003cb\u003eNew\u003c/b\u003e-\u003cb\u003eOrleans\u003c/b\u003e/",

  "pagemap": {

   "cse_image": [

    {

     "src":"http://www.arshtcenter.org/Global/Plays/2013/Jazz%20Roots/New_Orleans/jazz_roots-NewOrleans_690X310.jpg"

    }

   ],

   "cse_thumbnail": [

    {

     "width": "335",

     "height": "150",

     "src": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTv47Zi-QLCya4g3fbxlMisVCnlR5Ajarkbjxpa0rMYZhuAflvA1e20PW61"

    }

   ],

   "metatags": [

    {

     "viewport": "width=1024",

     "fb:app_id": "515420231834755",

     "og:title": "New Orleans: Aaron Neville & the DirtyDozen Brass Band",

     "og:site_name": "Adrienne Arsht Center",

     "og:url":"http://www.arshtcenter.org/Tickets/Calendar/2013-2014-Season/Jazz-Roots/New-Orleans/",

     "og:image":"http://www.arshtcenter.org/Global/Plays/2013/JazzRoots/New_Orleans/170x1003.jpg"

    }

   ]

}

}]


在一个array中还有很多内容,不是单纯用一个for循环就可以解决的。

对此感到很费解啊。。。怎么取出来。。。。

最后发现其实一句toString就解决了orz。。。。神烦。。

		//打开txt文件读入
		String result = readFileContent("F://independent study//temp1.txt");
		
		//System.out.println(fileContent);
		//将title link snippet 分别取出
		
        JSONObject dataJson = new JSONObject(result);
        //JSONObject items = new JSONObject("items");
        
        //queries,request,count
        JSONObject queries = dataJson.getJSONObject("queries");
        JSONArray request = queries.getJSONArray("request");
        JSONObject requestSet = request.getJSONObject(0);
        int count = requestSet.getInt("count");
        //System.out.println(count+"======================\n");
        
        
        JSONArray items = dataJson.getJSONArray("items");
        //JSONObject info = items.getJSONObject(0);
        String jsonstr = items.toString();


附上一个好用的解析json格式的网站

http://www.jsoneditoronline.org/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值