雪洗中关村

导航

json字符串格式

 

 

private static final String  COMPLEX_JSON_STR =
         "{" +
                 "\"teacherName\":\"crystall\"," +
                 "\"teacherAge\":27," +
                 "\"course\":{" +
                    "\"courseName\":\"english\"," +
                    "\"code\":1270" +
                 "}," +
                 "\"students\":[" +
                    "{" +
                        "\"studentName\":\"lily\"," +
                        "\"studentAge\":12" +
                    "}," +
                    "{" +
                        "\"studentName\":\"lucy\"," +
                        "\"studentAge\":15" +
                     "}" +
                 "]" +
         "}";

 

        String tmp = StringEscapeUtils.unescapeJavaScript(str);
        JSONObject jsonObject = JSON.parseObject(str, Feature.OrderedField);

//        JSONObject jsonObject = new JSONObject(true);
//        LinkedHashMap<String, Object> json = JSON.parseObject(str, LinkedHashMap.class, Feature.OrderedField);
//        jsonObject.putAll(json);
//        jsonObject.remove("crc");//去除crc字段

        String resStr = jsonObject.toJSONString();

 

posted on 2019-04-30 11:26  雪洗中关村  阅读(521)  评论(0编辑  收藏  举报