我有一个包含许多元素的 json 文件,例如:
{
"code" : "hfuiew89",
"type" : "location",
"coordinates" : [ { "lat" : 40.9861, "lon" : 29.1046, "index" : 1 },
{ "lat" : 40.9976, "lon" : 29.1153, "index" : 2 },
{ "lat" : 40.9809, "lon" : 29.2194, "index" : 3 }]
}
{
"code" : "klsdsjh",
"type" : "location",
"relatedTags" : [ "kolmha" ],
"coordinates" : [ { "lat" : 40.9808, "lon" : 29.1605, "index" : 1 },
{ "lat" : 40.9965, "lon" : 29.1672, "index" : 2 }]
}
我想用 gson 读取该文件,但我找到的所有示例都只针对一个元素。因此在阅读第一个之后,抛出“预期 EOF”异常。我该如何克服呢?