У меня был метод для преобразования InputStream в строковое представление JSON. Мне нужно было изменить подстроку с (intial, length () - 1) до (initial, length () - 2), чтобы она работала в 1.5 и 2.x. Спасибо за помощь.
private static String convertStreamToString(InputStream is) {
/*
* To convert the InputStream to String we use the BufferedReader.readLine()
* method. We iterate until the BufferedReader returns null which means
* there's no more data to read. Each line will appended to a StringBuilder
* and returned as String.
*/
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// API is defective and does not return correct json response.
// Reformat string response to confirm to expected json response
// return sb.toString();
return "{\"Results\":" + sb.substring(11, sb.length()-2) + "}\n" ;
}