需要處理的JSON數據中一個數組元素如下,請問如何定義一個類獲取它的數據(目的是把獲取的數據展示在一個tableview的cell中),我需要獲取text,user裡的screen name和profile_image_url所指向的圖像數據。我遇到的問題是在定義一個這樣的類時,user是不是要再定義一個類?在類裡不能鑲嵌一個類吧?如何定義它才能在後續處理中成功地將數據加載在tableview中?
{
"created_at": "Wed May 22 17:18:51 +0800 2013",
"id": 3580806792992860,
"mid": "3580806792992860",
"idstr": "3580806792992860",
"text": "服務器【星耀銀河】國家【燕】 浮沉江山英雄定,新的征程從五月十七號重新開始,誰將能主宰星耀銀河,誰又將是新興的霸主? 隨著一聲驚雷,小史降臨到了燕國這片熱土上,呼吸著新鮮的空……看全文點這 http://t.cn/zHy3fnC",
"source": "<a href=\"http://app.weibo.com/t/feed/4ZcXia\" rel=\"nofollow\">征途2國史應用</a>",
"favorited": false,
"truncated": false,
"in_reply_to_status_id": "",
"in_reply_to_user_id": "",
"in_reply_to_screen_name": "",
"pic_urls": [],
"geo": null,
"user": {
"id": 2866880570,
"idstr": "2866880570",
"screen_name": "開心驚玄",
"name": "開心驚玄",
"province": "33",
"city": "10",
"location": "浙江 台州",
"description": "",
"url": "",
"profile_image_url": "http://course.gdou.com/gxk/html/hw/1.jpg",
"profile_url": "u/2866880570",
"domain": "",
"weihao": "",
"gender": "m",
"followers_count": 131,
"friends_count": 239,
"statuses_count": 229,
"favourites_count": 0,
"created_at": "Wed Jul 11 19:16:18 +0800 2012",
"following": false,
"allow_all_act_msg": false,
"geo_enabled": true,
"verified": false,
"verified_type": -1,
"remark": "",
"allow_all_comment": true,
"avatar_large": "http://course.gdou.com/gxk/html/hw/2866880570180399998954401.jpg",
"verified_reason": "",
"follow_me": false,
"online_status": 0,
"bi_followers_count": 91,
"lang": "zh-cn",
"star": 0,
"mbtype": 0,
"mbrank": 0,
"block_word": 0
},
"reposts_count": 0,
"comments_count": 0,
"attitudes_count": 0,
"mlevel": 0,
"visible": {
"type": 0,
"list_id": 0
}
},
直接用swiftjson處理。然後用字典方式取對應的數據