又遇见一个奇妙问题。。。
现在我要把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/