MeknessiHamida
MeknessiHamida

Reputation: 185

GSON MalformedJsonException

I am using GSON to serialize my REST responses. I am getting this response from the server:

      {"idUser":1,"nom":"kaddour","prenom":"hanedi","login":"enit","password":"hanedi","genre":"f","adresse":"impasse chaabene merhbene","codePostal":8050,"tel":20333473,"active":1,"panneaux"}

and GSON is throwing a MalformedJsonException due to the last panneaux that has no value. How can I treat such response ? Thank you for your help.

Upvotes: 0

Views: 161

Answers (1)

Sanjay
Sanjay

Reputation: 127

You cannot handle such exceptions , since the response is an invalid JSON format and cannot be parsed at all using standard libraries.

You may write your own parser that parses character by character and discard keys without values.

Upvotes: 2

Related Questions