Converting String to Android JSONObject loses utf-8

前端 未结 4 493
盖世英雄少女心
盖世英雄少女心 2021-01-06 02:12

I am trying to get a (JSON formatted) String from a URL and consume it as a Json object. I lose UTF-8 encoding when I convert the String to JSONObject.

This is The f

4条回答
  •  爱一瞬间的悲伤
    2021-01-06 02:38

    Not sure if this will help, but you might be able to do something like this:

    JSONObject result = null;
    String str = null;
    try 
    {           
        str = new String(output, "UTF-8");
        result = (JSONObject) new JSONTokener(str).nextValue();
    } 
    catch (Exception e) {}
    
    String messages = result.getString("messages");
    

提交回复
热议问题