Android的解析在JSON响应特殊字符 [英] Android parse special characters in json response

查看:298
本文介绍了Android的解析在JSON响应特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我从一个PHP URL JSON响应字符串。从响应我得到一些酒店名称以撇号,我得到&放大器;#039 字符而不是撇号。我怎样才能解析与Android的特殊字符的酒店? 我可以看到在浏览器中的撇号,但在Android的logcat中都看不到。

我曾尝试 jresponse = URLEn coder.en code(jresponse,UTF-8); ,但我无法让撇号酒店名称。

这是在响应中的饭店的名称之一。

 我看到浏览器下面。    {ID:12747,
     名:奥斯卡
     ....
    }
但在logcat中:     ID 12747
     奥斯卡的名字和放大器;#039;


解决方案

您可以尝试的Html类。例如: -
jresponse = Html.fromHtml(jresponse);

In my Android application I get JSON response string from a PHP url. from the response I get some hotel names with apostrophe, I get &#039 character instead of apostrophe. How can I parse the hotel with special characters in android? I can see the apostrophe in the browser but could not see in android logcat.

I have tried jresponse = URLEncoder.encode(jresponse,"UTF-8"); but I could not get apostrophe for hotel name.

This is the one of the hotel name in the response.

 I see the following in browser.

    {"id":12747,
     "name":"Oscar's",
     ....
    }
But in the logcat:

     id 12747
     name Oscar's

解决方案

You can try Html class. eg :- jresponse = Html.fromHtml(jresponse);

这篇关于Android的解析在JSON响应特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆