How in json line replace unicode on utf8?



  • Like this line:

    {"type":"item","data":{"i_quality":"\\u041D\\u043E\\u0432\\u043E\\u0435","color":"D2D2D2"}}
    

    Convert to this:

    {"type":"item","data":{"i_quality":"Новое","color":"D2D2D2"}}
    

    The line code will look like:

    String s = "{\"type\":\"item\",\"data\":{\"i_quality\":\"\\\\u041D\\\\u043E\\\\u0432\\\\u043E\\\\u0435\",\"color\":\"D2D2D2\"}}";
    


  • Try this:

    String string = "{"type":"item","data":{"i_quality":"\\u041D\\u043E\\u0432\\u043E\\u0435","color":"D2D2D2"}}";
    byte[] utf8 = string.getBytes("UTF-8");
    string = new String(utf8, "UTF-8");
    

    https://docs.oracle.com/javase/tutorial/i18n/text/string.html




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2