Outputting Special Characters From JSON Webservice
Hello there,
I am trying to use Google Translate API to translate different texts from a language to another and I am facing problems with special characters like.
For instance, I am getting this response from Google Translate API if I am using a HTTP get (ex. https://www.googleapis.com/language/translate/v2?[YOUR_API_KEY_HERE]&source=ro&target=de&q=Hotelul%20este%20asezat%20la%20o%20altitudine%20de%20700%20m%20in%20statiunea%20Crivaia%20Pentru%20grupuri%20mai%20mari%20tarifele%20sunt%20speciale,%20negociabile!)
{
"data": {
"translations": [
{
"translatedText": "Das Hotel liegt auf einer Höhe von 700 m im Ort Crivaia Für größere Gruppen Sonderkonditionen verhandelbar sind entfernt!"
}
]
}
}
Notice ö, ü, ß, and other "special characters" from German language.
If I am using CFHTTP and POST method and so on, when I CFDUMP the result I get this:
| struct | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| data |
| ||||||||||||
Notice all the messed up chars.
I think the responsible for this mess up is deserializeJSON() function I am using to get the text result from the fileContent response: <cfset data = deserializeJSON(result.fileContent)>
What you see above is a <CFDUMP> of "data".
Do you know how can I convince deserializeJSON() to return the correct special chars?
Adrian
