json字符串取特定元素值

1、json字符串为 { "key" : "value" }

import com.alibaba.fastjson.JSONObject;
    //json字符号转换为json对象,然后获得key对应value
    public static String getJsonValue(String jsonStr, String key) {

        JSONObject jsonObj = JSONObject.parseObject(jsonStr);
        return jsonObj.get(key).toString();

    }

 

posted @ 2020-03-12 19:13  活出自己范儿  Views(1662)  Comments(0Edit  收藏  举报