A solution to automatically convert special characters into Unicode when taking out data from MySQL and encapsulating it into JSON

    @Test
    public void xxx() throws ParseException, UnsupportedEncodingException, Exception {
        ArrayList<JSONObject> list = new ArrayList<>();
        String s = "Appliances jerry-built, poor quality clothing ...... still believe that "e-commerce custom products" more affordable";
        JSONObject json = new JSONObject();
        json.put("title", s);
        JSONObject json1 = new JSONObject();
        json1.put("title", s);
        list.add(json);
        list.add(json1);
        System.out.println("old:"+list.toString());
        System.out.println("new"+StringEscapeUtils.unescapeJava(list.toString()));
    }

Output:
before transformation: [{“title”: “home appliances cut corners and poor clothing quality”}]
after transformation [{“title”: “home appliances cut corners and poor clothing quality”}]
after transformation [{“title”: “home appliances cut corners and poor clothing quality”} Also believe that “e-commerce customized products” are more affordable “}, {” title “:” home appliances cut corners, poor quality of clothing Also believe that “e-commerce customized products” are more affordable “}]

Read More: