我得到以下 JSON 输出:
{
"range": "Frontpage!E6:E15",
"majorDimension": "ROWS",
"values": [
[
"FundRequest"
],
[
"nOS"
],
[
"NEX"
],
[
"DREP"
],
[
"ChromaWay"
],
[
"Jura"
],
[
"Origo"
],
[
"Phantasma"
],
[
"NuCypher"
],
[
"Oasis Labs"
]
]
}
所以我创建了以下包装器:
public class Wrapper {
private String range;
private String majorDimension;
private List<String> values;
// getters and setters
}
现在我想GsonBuilder用来将 JSON 映射到我的对象:
Gson gson = new GsonBuilder().create();
Wrapper w = gson.fromJson(jsonString, Wrapper.class);
但我收到以下错误:
java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 37 path $.values[0]
我如何解决它?我有什么办法可以将它从 a 转换List<List<String>>为 aList<String>吗?
郎朗坤
相关分类