我在构建一个可以解析 gson 的类时遇到了一些麻烦,正如我所期望的那样。
我创建了一个类。
public class JsonObjectBreakDown {
public String type;
public List<String> coordinates = new ArrayList<String>();
}
并叫
JsonObjectBreakDown p = gson.fromJson(withDup, JsonObjectBreakDown.class);
下面是我的json
{
"type":"Polygon",
"coordinates":[
[
[
-66.9,
18.05
],
[
-66.9,
18.05
],
[
-66.9,
18.06
],
[
-66.9,
18.05
]
]
]
}
我以前成功地使用过 gson,但从来没有使用过这样的数组。我不应该使用 List/ArrayList 吗?
我收到错误消息;
Exception in thread "main" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 31
OpenCSV 代码
CSVReader reader = new CSVReader(new FileReader("c:\\Json.csv"));
String tmp = reader.readNext();
CustomObject tmpObj = CustomObject(tmp[0], tmp[1],......);