2
我會去解析使用谷歌GSON庫JSON嗎?我返回的JSON的一個示例是:如何閱讀與Gson的Json
[
{
"title": "Down",
"album": "Down",
"length": 212.61,
"artist": "Jay Sean"
},
{
"title": "Come to Me (Peace)",
"album": "Growing Pains",
"length": 301.844,
"artist": "Mary J Blige"
}
]
這是一個json對象數組,是嗎?我將如何去與Gson解壓縮?這是即時通訊嘗試,但我得到空指針例外:
JsonElement jelement = new JsonParser().parse(jsonInfo);
JsonObject jobject = jelement.getAsJsonObject();
jobject = jobject.getAsJsonObject("");
JsonArray jarray = jobject.getAsJsonArray("");
jobject = jarray.get(0).getAsJsonObject();
String result = jobject.get("title").toString();
啊,所以我確實需要一個對象。謝謝 –