码迷,mamicode.com
首页 > Web开发 > 详细

验证是否是json语句-用于json断言

时间:2017-07-04 21:51:37      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:lag   ring   this   开始   his   语句   public   ati   char   

public class TestFast {
public static void main(String[]args){
String resp="";
int length=resp.length();
int flag=-1;
if(length>2){
int i=0;
// 从第1位的字符开始找,是不是{,如果不是,查看下一个,找到第n个,还不是,就报错

while(i<3){
if(resp.charAt(i)==123){
flag=0;
break;
}

else{
i++;
}

}
if(flag==0){
System.out.println("this is a json");
}else{
System.out.println("this is not a json");
}
//不是,就判断失败,给出结论

}else {
System.out.println("the response is not a json,the length is 0 or 1,or 2(not {})");
}
}
}

验证是否是json语句-用于json断言

标签:lag   ring   this   开始   his   语句   public   ati   char   

原文地址:http://www.cnblogs.com/zhizhiyin/p/7118245.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!