要解析的json字符串:
{
"ROOT": {
"HEADER": {
"ROUTING": {
"ROUTE_KEY": "",
"ROUTE_VALUE": ""
}
},
"BODY": {
"OUT_DATA": {
"TABLES": [{
"TABLENAME": "BS_FUNCTION_DICT",
"DATARECORDS": [{
"COLS": {
"FUNCTION_CODE": "2923",
"FUNCTION_NAME": "权限信息管理"
},
"OP": "I"
}]
}]
}
}
}
}
实现代码如下:
String content = " {\n" +
"\t\"ROOT\": {\n" +
"\t\t\"HEADER\": {\n" +
"\t\t\t\"ROUTING\": {\n" +
"\t\t\t\t\"ROUTE_KEY\": \"\",\n" +
"\t\t\t\t\"ROUTE_VALUE\": \"\"\n" +
"\t\t\t}\n" +
"\t\t},\n" +
"\t\t\"BODY\": {\n" +
"\t\t\t\"OUT_DATA\": {\n" +
"\t\t\t\t\"TABLES\": [{\n" +
"\t\t\t\t\t\"TABLENAME\": \"BS_FUNCTION_DICT\", \n" +
"\t\t\t\t\t\"DATARECORDS\": [{\n" +
"\t\t\t\t\t\t\"COLS\": {\n" +
"\t\t\t\t\t\t\t\"FUNCTION_CODE\": \"2923\",\n" +
"\t\t\t\t\t\t\t\"FUNCTION_NAME\": \"权限信息管理\" \n" +
"\t\t\t\t\t\t},\n" +
"\t\t\t\t\t\t\"OP\": \"I\" \n" +
"\t\t\t\t\t}]\n" +
"\t\t\t\t}]\n" +
"\t\t\t}\n" +
"\t\t}\n" +
"\t}\n" +
"}";
String regex = "\"TABLENAME\": \"(.*?)\",";
Matcher matcher = Pattern.compile(regex).matcher(content);
if (matcher.find()) {
String tableName = matcher.group(1);
System.out.println(tableName);
}
参考:
1.http://blog.csdn.net/yangruihong/article/details/17245359;
最新评论
网飞没问题, 迪士尼+有解决方案么?
pp助手是安卓手机用的,根本下载用不来苹果
已解决
这样的话数据库里的结构为{"attachment":{"content":"xxx"}}, 要怎么才能变成{"content":"xxx"},从而使结构保持一致?
赞! make test不过的坑都写到的,谢谢楼主~
谢谢你
用了root用户还是一直502是怎么回事呢
student id 是空的