有一個Float值列表的列表作爲Json,怎麼可能得到List<List<Float>>
?Java Json到列表清單
我想是這樣的:
class MyLine{
List<Float> values;
}
String firstData = "[[0.11492168, -0.30645782, 9.835381], [0.12449849, -0.29688102, 9.844957]]"
Gson gson = new Gson();
List<MyLine> firstList = gson.fromJson(firstData, new TypeToken<List<MyLine>>(){}.getType());
,但我有一個錯誤Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 3 path $[0]
。我的代碼有什麼問題?
用過gson嗎? – Remario
是你的字符串中有效的JSON? –
@jackjay是的 – littlewombat