Page 1 of 1

Wie kann man einen JSON mit GSON nicht realisieren? Einen Fehler erhalten

Posted: 31 Aug 2025, 13:04
by Anonymous
Die Struktur des JSON, die ich in einer Zeichenfolge gespeichert habe, lautet: < /p>

{
"0": {
"PDate": "2019-02-25 00:00:00.0000000",
"DDate": "2019-06-25 00:00:00.0000000",
"Document": "FC",
"Direction": "CALLE ...."
},
"1": {
"PDate": "2019-02-25 00:00:00.0000000",
"DDate": "2019-06-25 00:00:00.0000000",
"Document": "FC",
"Direction": "CALLE ...."
}
}
< /code>

Ich verwende den folgenden Code, aber es zeigt einen Fehler in der letzten Zeile an: < /p>

if (response.isSuccessful()){
Object object = response.body();
String jsonString = String.valueOf(object);
Gson gson = new Gson();

Type empMapType = new TypeToken() {}.getType();
Map nameObjectJson = gson.fromJson(jsonString, empMapType);
}
< /code>

Die Fehlermeldung: < /p>

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 29 path $..PostingDate
< /code>

Bitte, ich brauche Hilfe. Danke