public class JetfStringJson implements ToJson<String> { @Override public void toJson(String value, int depth, JsonResult ret) { boolean b = true; // LogUtils.log(value); if (StrKit.notBlank(value.toString())) { try { // ret.addUnknown(obj); // ret.addStr(); addJSONStr(JSONObject.parseObject(value.toString()).toString(), ret); b = false; } catch (Exception e) { try { // ret.addStr(JSONObject.parseArray(value.toString()).toString()); addJSONStr(JSONObject.parseArray(value.toString()).toString(), ret); b = false; } catch (Exception e1) { } } } if (b) { ret.addStr(value); } } private void addJSONStr(String s, JsonResult ret) { for (int i = 0, len = s.length(); i < len; i++) { char ch = s.charAt(i); if ((ch >= '\u0000' && ch <= '\u001F') || (ch >= '\u007F' && ch <= '\u009F') || (ch >= '\u2000' && ch <= '\u20FF')) { String str = Integer.toHexString(ch); ret.addChar('\\'); ret.addChar('u'); for (int k = 0; k < 4 - str.length(); k++) { ret.addChar('0'); } for (int j = 0; j < str.length(); j++) { char ch1 = str.charAt(j); ret.addChar(ch1); } } else { ret.addChar(ch); } } } }
https://jfinal.com/feedback/8147这个问题在@JFinal的协助下已解决,以上是处理方案,