sql修改数据库里面的json字段 判断json内容是否符合格式:
public static void main(String[] args) throws Exception {
String a = "\\'\\S*\\'";//正则
Pattern p = Pattern.compile(a);
BufferedReader br = new BufferedReader(new FileReader("D:\\config.sql"));
String line = null;
int i = 0;
while ((line = br.readLine()) != null) {
i++;
Matcher m = p.matcher(line);
while(m.find()) {
String json = m.group().replace("'", "");
try {
JSON.parseArray(json);
}catch (JSONException e){
System.out.println("第"+i+"行 "+ json);
}
}
}
br.close();
}