map转json

版权声明:Life's tragedy is that we get old too soon and wise too late. https://blog.csdn.net/Love_Legain/article/details/80351313
    public static String map2json(Map<?, ?> map) {
        StringBuilder json = new StringBuilder();
        json.append("{");
        if (map != null && map.size() > 0) {
            for (Object key : map.keySet()) {
                json.append(object2json(key));
                json.append(":");
                json.append(object2json(map.get(key)));
                json.append(",");
            }
            json.setCharAt(json.length() - 1, '}');
        } else {
            json.append("}");
        }
        return json.toString();
    }
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页