JSON正则表达式通过key 获取 value

    public static void main(String[] args) {
        String str = "{\"inputType\":\"INPUT_PC\"}";
        String key = "inputType";
        Pattern pattern = Pattern.compile(key + "\":\"(.*?)\"");
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
        }
    }

 

posted @ 2022-03-02 21:14  暮云寒水  阅读(383)  评论(0)    收藏  举报