Detecting and parsing escape character "\" from JSON file?

I have a problem with data that is a JSON file. I am using the following link from google.

http://www.google.com/finance/company_news?q=AAPL&output=json"

My problem arises when I want to analyze data and put it on the screen. For some reason, the data is not decoded properly.

Initial data:

 1.) one which must have set many of the company\x26#39;s board on the edge of their
 2.) Making Less Money From Next \x3cb\x3e...\x3c/b\x3e

When I enter the data, I do the following:

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();        
BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8); 
StringBuilder sb = new StringBuilder();
String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "n");
}
is.close();
json = sb.toString();

The output I get using org.json to extract data from a json file is as follows (note the absence of a backslash):

1.)one which must have set many of the companyx26#39;s board on the edge of their
2.)Making Less Money From Next x3cbx3e...x3c/bx3e

my current method of handling the first problem:

JSONRowData.setJTitle((Html.fromHtml((article.getString(TAG_TITLE).replaceAll("x26", "&")))).toString());

the second eludes me though (pun intended)

, , , , escape-. Ive , ive . ?


: "\ x26" - ASCII ( )

Char. commons.io apache - . , Char for, "\", , "x" . , Char. ASCII. , char. .

( "\" ), Char . .toString() .

HTML ('/ ). Html.fromHtml() .

+3
1

, google - , , url - JSON 1,2. JSON, JSON, ", \nonsense " . , , , .

1 , \x ( , \ ), \ ( ) ( x). \u1234, \x12.

"", , - : \x12 \u0012. ( , - , - , ! Google.)

2 JSON:

Apple Inc. (NASDAQ: AAPL) - . \x26 # 39 , .

( , \x26 \u0026 &.)

- :)


Java [] ( String.replaceAll):

inputString.replaceAll("\\x(\d{2})", "\\u00$1") 
+3

All Articles