I’m trying to make an Android application that need to access some webservices, returning data in JSon format.
I’m using Gson to parse these data, and never had any problem with this library.
Thing is, apparently, one the webservices is returning me a String with html tags in it (actually, starting with HTML tag). The problem is, even if I have no exception while parsing the string, this particular fields appears to be empty at the output.
the Json i’m trying to parse looks like this :
{
"ID": "66",
"Nom": "Bordeaux",
"Pays": "FRANCE",
"Titre_office": "Office de Tourisme de",
"Descriptif_office": "<a href=\"http://www.secure-hotel-booking.com/office-de-tourisme-de-bordeaux/2T66/dateselection?sid=1811faff-feda-4f98-83b5-89d6eb6266e8\">Disponibilités des hébergements en ville</a> Bordeaux, ville riche en histoires et en lieux, avec son fabuleux patrimoine mondial, sa culture, sa gastronomie et son art de vivre, vous accueille toute l'année pour profiter d'un excellent moment.",
"Logo_office": "ville_66.jpg",
"Adresse_office": "blabla",
"Num_contact": "+33xxxxxxxxxx",
"Mail_contact": "xxx@mail.com",
"Site_contact": "http://www.bordeaux-tourisme.com"
}
Of course, all the fields are ok, except for the “Descriptif_office” one.
I tried to use new GsonBuilder().disableHtmlEscaping().create(); but with strictly no effet…
Any help would be greatly appreciated !
Thanks
Edit :
I have no problem when using hard coded string :
new GsonBuilder().disableHtmlEscaping().create().fromJson(new StringReader(" {\"Descriptif_office\":\"<a href=\\\"http:\\/\\/www.secure-hotel-booking.com\\/office-de-tourisme-de-bordeaux\\/2T66\\/dateselection?sid=1811faff-feda-4f98-83b5-89d6eb6266e8\\\">Disponibilit\\u00e9s des h\u00e9bergements en ville<\\/a> Bordeaux, ville riche en histoires et en lieux, avec son fabuleux patrimoine mondial, sa culture, sa gastronomie et son art de vivre, vous accueille toute l'ann\u00e9e pour profiter d'un excellent moment.\"}"), test.class);
Always check you are calling the right webservice. Stupid me.