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