liuxiaolong
2019-05-06 a7bed6b4cfecd61ec153818945f982c5bb796b98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.cloud.common.utils;
 
import com.alibaba.fastjson.JSONObject;
 
import java.util.Map;
/**
 * json工具类
 * @author lp
 * @date 2018-08-05
 */
public class JsonUtil {
 
    /**
     * 字符串转json
     */
    public static JSONObject stringToJson(String str){
        //将字符串{“id”:1}装换成json
        JSONObject jsStr = JSONObject.parseObject(str);
        return jsStr;
    }
 
    /**
     * map转json
     */
    public static JSONObject mapToJson(Map<String, Object> map){
        JSONObject jsStr =  JSONObject.parseObject(JSONObject.toJSONString(map));
        return jsStr;
    }
}