救急啊.....
在写新浪微博客户端时遇到了问题,用JsonReader解析微博返回数据时显示如下错误
java.lang.IllegalStateException: Expected a name but was STRING at line 1 column 47
相关代码如下:
    public long getWeiBoId(String JsonData){
     long weiboId = 0;
     try{
     JsonReader reader = new JsonReader(new StringReader(JsonData));
     reader.beginObject();
     while(reader.hasNext()){
     String tagName = reader.nextName();
     if(tagName.equals("id")){
     weiboId = reader.nextLong();
     }
     }
     reader.endObject();
     }catch(Exception e){
     e.printStackTrace();
     }
     return weiboId;
    }
返回的Json字符串如下:
{"created_at":"Fri Aug 17 14:16:04 +0800 2012","id":3480016971496941,"mid":"3480016971496941","idstr":"3480016971496941","text":"Json ","source":"<a href=\"http://open.t.sina.com.cn\" rel=\"nofollow\">未通过审核应用</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"user":{"id":2049309993,"idstr":"2049309993","screen_name":"A_littlemore","name":"A_littlemore","province":"11","city":"8","location":"北京 海淀区","description":"","url":"","profile_image_url":"http://tp2.sinaimg.cn/2049309993/50/5614835694/1","profile_url":"u/2049309993","domain":"","weihao":"","gender":"m","followers_count":98,"friends_count":86,"statuses_count":83,"favourites_count":0,"created_at":"Sat Oct 29 13:27:35 +0800 2011","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"verified_type":-1,"allow_all_comment":true,"avatar_large":"http://tp2.sinaimg.cn/2049309993/180/5614835694/1","verified_reason":"","follow_me":false,"online_status":0,"bi_followers_count":36,"lang":"zh-cn"},"reposts_count":0,"comments_count":0,"mlevel":0,"visible":{"type":0,"list_id":0}}...经检测在解析完created_at后再次执行hasNext()时,reader内部的name属性为null....不知道是什么原因怎么解决呢,求各位大侠帮忙啊.....