0
我正在使用谷歌趨勢獲得微粒關鍵字的趨勢。它會返回JSON,但主要的問題是,我想創建一個持有數據並在java代碼中用作數組List的類。 我很困惑什麼是它的類結構當我得到的結果看起來像下面谷歌趨勢api結果在java
{"version":"0.6","status":"ok","sig":"1248242565",
"table":
{ "cols":
[{"id":"date","label":"Date","type":"date","pattern":""},
{"id":"query0","label":"linkedin","type":"number","pattern":""},
{"id":"query1","label":"facebook","type":"number","pattern":""}],
"rows":[{"c":[{"v":new Date(2004,0,1),"f":"January 2004"},{"v":0.0,"f":"0"},{"v":0.0,"f":"0"}]},
{"c":[{"v":new Date(2004,5,1),"f":"June 2004"},{"v":0.0,"f":"0"}, {"v":0.0,"f":"0"}]},
{"c":[{"v":new Date(2004,8,1),"f":"September 2004"},{"v":0.0,"f":"0"},{"v":0.0,"f":"0"}]},
{"c":[{"v":new Date(2013,9,1),"f":"October 2013"},{"v":1.0,"f":"1"},{"v":83.0,"f":"83"}]}]
}
}
它將返回的搜索查詢行和cols如果我搜索兩個單獨的字,結果是像上面JSON。不知道我怎麼能讓類Trend.java和該列表對象,包含所有這些信息
cols值是動態的,現在它可能是2或4也是基於搜索。 我想將所有這個列表或地圖存儲在一個java類對象中 –
那麼你可以在類「Trend」中包裝這個'List'。至於動態列,'HashMap'可以存儲任意數量的列。該解決方案適合。你所要做的就是弄清楚如何循環訪問'JSON'值。 – christopher