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)); } }
浙公网安备 33010602011771号