我有以下 JSON 字符串:
{
"ms": "images,5160.1",
"turl": "http://ts1.mm.bing.net/th?id=I4693880201938488&pid=1.1",
"height": "178",
"width": "300",
"imgurl": "http://www.attackingsoccer.com/wp-content/uploads/2011/07/World-Cup-2012-Draw.jpg",
"offset": "0",
"t": "World Cup 2014 Qualification – Europe Draw World Cup 2012 Draw ...",
"w": "719",
"h": "427",
"ff": "jpeg",
"fs": "52",
"durl": "www.attackingsoccer.com/2011/07/world-cup-2012-qualification-europe...",
"surl": "http://www.attackingsoccer.com/2011/07/world-cup-2012-qualification-europe-draw/world-cup-2012-draw/",
"mid": "D9E91A0BA6F9E4C65C82452E2A5604BAC8744F1B",
"k": "6",
"ns": "API.images"
}
我需要将 的值存储imgurl
在一个单独的字符串中。
这是我到目前为止所拥有的,但这只是给了我整个 JSON 字符串而不是特定的 imgurl 字段。
Gson gson = new Gson();
Data data = new Data();
data = gson.fromJson(toExtract, Data.class);
System.out.println(data);
toExtract
是 JSON 字符串。这是我的数据类:
public class Data
{
public List<urlString> myurls;
}
class urlString
{
String imgurl;
}