用正则解析JSON
来源:互联网 发布:linux windows samba 编辑:程序博客网 时间:2024/05/18 20:08
private void getData(String str){
apptxt="";
ImgList=new ArrayList<String>();
newsList=new ArrayList<News>();
String s=str.replace("...", "");
str=s;
int i=1;
Pattern pattern = Pattern.compile("\\{\"link\":\"(.+?)\",\"title\":\"(.+?)\",\"image\":\"(|.+?)\",\"brief\":\"(|.+?)\",\"content\":\"(|.+?)\",\"time\":\"(|.+?)\",\"n_read\":(|.+?),\"n_like\":(.+?)\\}");
Matcher matcher = pattern.matcher(str);
//str="";
boolean ist=false;
while (matcher.find()) {
news=new News();
news.setlink(matcher.group(1));
news.setTitle(matcher.group(2));
news.setContent(matcher.group(3));
news.setContent(matcher.group(5));
news.settxt(matcher.group(5));
newsList.add(news);
ImgList.add(matcher.group(3));
ist=true;
}
if(caxun("appset","saveis")==null){
insert("appset","saveis","no");
}
if(ist==true && caxun("apititle",appurl)==null && gis(caxun("appset","saveis"),"ye")){
insert("apititle",appurl,str);
dog("已自动保存数据");
dog();
}
if(ist==true && gis(caxun("appset","saveis"),"no")){
apptxt=str;
}
adapter=new NewsAdapter(MainActivity.this, newsList, ImgList);
ScaleInAnimationAdapter scaleInAnimationAdapter = new ScaleInAnimationAdapter(adapter, 0f);
scaleInAnimationAdapter.setListView(listView);
listView.setAdapter(scaleInAnimationAdapter);
}
apptxt="";
ImgList=new ArrayList<String>();
newsList=new ArrayList<News>();
String s=str.replace("...", "");
str=s;
int i=1;
Pattern pattern = Pattern.compile("\\{\"link\":\"(.+?)\",\"title\":\"(.+?)\",\"image\":\"(|.+?)\",\"brief\":\"(|.+?)\",\"content\":\"(|.+?)\",\"time\":\"(|.+?)\",\"n_read\":(|.+?),\"n_like\":(.+?)\\}");
Matcher matcher = pattern.matcher(str);
//str="";
boolean ist=false;
while (matcher.find()) {
news=new News();
news.setlink(matcher.group(1));
news.setTitle(matcher.group(2));
news.setContent(matcher.group(3));
news.setContent(matcher.group(5));
news.settxt(matcher.group(5));
newsList.add(news);
ImgList.add(matcher.group(3));
ist=true;
}
if(caxun("appset","saveis")==null){
insert("appset","saveis","no");
}
if(ist==true && caxun("apititle",appurl)==null && gis(caxun("appset","saveis"),"ye")){
insert("apititle",appurl,str);
dog("已自动保存数据");
dog();
}
if(ist==true && gis(caxun("appset","saveis"),"no")){
apptxt=str;
}
adapter=new NewsAdapter(MainActivity.this, newsList, ImgList);
ScaleInAnimationAdapter scaleInAnimationAdapter = new ScaleInAnimationAdapter(adapter, 0f);
scaleInAnimationAdapter.setListView(listView);
listView.setAdapter(scaleInAnimationAdapter);
}
0 0
- 用正则解析JSON
- json 在线解析 正则在线解析
- 用JQuery解析Json
- python解析json串与正则匹配对比
- [Python]爬虫,正则表达式解析网页及Json序列化
- android解析JSON数据;android正则查找指定字符串
- 【JSON解析】JSON解析
- Android上用Jackson Json解析json
- xUtils获取json用gson解析json
- 【Android】解析Json对象,用自带json解析器
- Android--用JSON解析数据
- 用nodejs解析json数据
- 用Gson解析json数据
- java : 用 gson 解析 JSON
- Android用Gson解析Json
- 用Python解析json数据
- 用 logstash 解析 json 数组
- 用typeToken解析json串
- TP-LINK虚拟服务器(端口映射)设置指导
- 单例模式
- Python后端[爱伍]
- Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置
- 素数基本结论及应用
- 用正则解析JSON
- 浅析HTTP中Get和Post的区别
- 阿里小Ai之父解析阿里大数据在新兴行业的应用
- python第一只爬虫:爬豆瓣top250
- 文字横向不间断滚动js代码
- properties文件动态修改并自动保存
- TF-IDF 原始用去 计算判断 某个词语对文章的重要性
- stringstream的基本用法
- js RSA加密 java解密方式