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

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie kann man einen JSON mit GSON nicht realisieren? Einen Fehler erhalten

by Anonymous » 31 Aug 2025, 13:04

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

Top