I have a problem with data that is a JSON file. I am using the following link from google.
http:
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
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
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() .