1
所有StackOverflow答案没有帮助我。根据他们和我搜索的所有其他地方,我的JSON看起来是正确的,看起来很好。Gson预计BEGIN_ARRAY,但是STRING
我无法加载我的JSON文件在Java中,我真的需要在这方面的帮助。
这里是我的JSON
{"evento":
{"descricao":"saf","finalizado":false,"id":1,"localEvento":"asufgb","nome":"Teste",
"convidados":
[{"acompanhante":null,"id":"28147",
"localHospedagem":"ATLANTE PLAZA","nome":"FooBar","nomeCracha":"FOO","observacoes":null,"participante":null,
"publico":"FROTISTAS"}
]}}
这里是我的代码
JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(filePath)));
JsonObject obj = parser.parse(reader).getAsJsonObject();
Evento evento = gson.fromJson(obj.get("evento"), Evento.class);
和错误
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING
at com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:139)
谁能请告诉我,我究竟做错了什么?
您的哪行代码触发错误? – mpierce 2013-04-04 22:30:08