Reputation: 1
URI uri = new URI(api);
URL url = uri.toURL();
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestProperty("Content-Type", "application/json;UTF-8");
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
StringBuilder sb = new StringBuilder();
int a;
while ((a = br.read()) != -1) {
sb.append((char)a);
}
JSONParser jsonParser = new JSONParser();
Object obj = jsonParser.parse(sb.toString());
responseJson = (JSONObject) obj;
I want to get the string as UTF-8, but it is garbled. Like this "fcstValue":"��"
I tried to read it in UTF-8 format from api with UTF-8 but failed.
Upvotes: 0
Views: 41