搜索
查看: 2706|回复: 3

求助:web.json.parse()读取domains下的所有id跟name

[复制链接]

26

主题

103

帖子

780

积分

三级会员

Rank: 4

积分
780
发表于 2013-12-26 22:35:57 | 显示全部楼层 |阅读模式
{
"status":
        {"code":"1","message":"Action completed successful","created_at":"2013-12-26 18:00:05"},
"info":{"domain_total":3,"all_total":3,"mine_total":3,"share_total":0,"vip_total":0,"ismark_total":0,"pause_total":0,"error_total":0,"lock_total":0,"spam_total":0,"vip_expire":0,"share_out_total":0},


"domains":[
               {"id":832321,
        "name":"loyi.com",
        "grade":"D_Free",
        "grade_title":"\u514d\u8d39\u5957\u9910",
        "status":"enable",
        "ext_status":"",
        "records":"14",
        "group_id":"1",
        "is_mark":"no",
        "remark":"",
        "is_vip":"no",
        "searchengine_push":"yes",
        "beian":"no",
        "created_on":"2011-08-03 19:06:45",
        "updated_on":"2013-12-26 16:50:19",
        "ttl":"600",
        "owner":"xxx@qq.com"
        },               
        {"id":981321,"name":"pack.com","grade":"DP_Free","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","status":"enable","ext_status":"","records":"5","group_id":"1","is_mark":"no","remark":"","is_vip":"no","searchengine_push":"yes","beian":"no","created_on":"2013-10-09 02:02:42","updated_on":"2013-11-24 18:16:46","ttl":"600","owner":"xxx@qq.com"},               
]
}
怎么样用web.json.parse()读取domains下的所有id跟name
回复

使用道具 举报

2

主题

48

帖子

1198

积分

四级会员

Rank: 6Rank: 6

积分
1198
QQ
发表于 2013-12-26 23:37:13 | 显示全部楼层

[i=s] 本帖最后由 CP3 于 2013-12-26 23:38 编辑 [/i] [code][lang=aardio,false] io.open()

本帖最后由 CP3 于 2013-12-26 23:38 编辑

  1. io.open();//打开控制台
  2. import web.json
  3. var str = /**

  4. {
  5. "status":
  6.         {"code":"1","message":"Action completed successful","created_at":"2013-12-26 18:00:05"},
  7. "info":{"domain_total":3,"all_total":3,"mine_total":3,"share_total":0,"vip_total":0,"ismark_total":0,"pause_total":0,"error_total":0,"lock_total":0,"spam_total":0,"vip_expire":0,"share_out_total":0},


  8. "domains":[
  9.                {"id":832321,
  10.         "name":"loyi.com",
  11.         "grade":"D_Free",
  12.         "grade_title":"\u514d\u8d39\u5957\u9910",
  13.         "status":"enable",
  14.         "ext_status":"",
  15.         "records":"14",
  16.         "group_id":"1",
  17.         "is_mark":"no",
  18.         "remark":"",
  19.         "is_vip":"no",
  20.         "searchengine_push":"yes",
  21.         "beian":"no",
  22.         "created_on":"2011-08-03 19:06:45",
  23.         "updated_on":"2013-12-26 16:50:19",
  24.         "ttl":"600",
  25.         "owner":"xxx@qq.com"
  26.         },               
  27.         {"id":981321,"name":"pack.com","grade":"DP_Free","grade_title":"\u65b0\u514d\u8d39\u5957\u9910","status":"enable","ext_status":"","records":"5","group_id":"1","is_mark":"no","remark":"","is_vip":"no","searchengine_push":"yes","beian":"no","created_on":"2013-10-09 02:02:42","updated_on":"2013-11-24 18:16:46","ttl":"600","owner":"xxx@qq.com"},               
  28. ]
  29. }
  30. **/
  31. var t = web.json.parse(str)
  32. for(i=1;#t.domains;1){
  33.         io.print("id:",t.domains[ i ].id,"name:",t.domains[ i ].name)
  34. }


  35. execute("pause") //按任意键继续
  36. io.close();//关闭控制台

复制代码

点评

同意: 5.0 真棒: 5.0
同意: 5 真棒: 5
太好了 谢谢你,又学会了一个  发表于 2013-12-26 23:44
一曲且为梦中人..
回复

使用道具 举报

1

主题

13

帖子

81

积分

荣誉会员

Rank: 8Rank: 8

积分
81
发表于 2017-9-24 16:30:46 | 显示全部楼层
本帖最后由 桂桂 于 2017-9-24 16:32 编辑

很不错,这一个最好是要注意一点,
var t = web.json.parse(str)//这一个解析出来后,最好用哪一个console.dump(T)显示出来看一下,有时他有三层,所以一定要注意
如( for (1=1#t.domains.rows;1))
for(i=1;#t.domains;1){
        io.print("id:",t.domains[ i ].id,"name:",t.domains[ i ].name)
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

手机版|未经许可严禁引用或转载本站文章|站长邮箱|aardio.com|aardio官方社区 ( 皖ICP备09012014号 )

GMT+8, 2018-10-20 03:28 , Processed in 0.093750 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表