• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ruby-检查json数据类型

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
HashObj={"id"=>"fae6e87e932c29a0c177512151114f22","at"=>2,"app"=>{"id"=>"9d66d9249cc5bd549b0e68b9fedc69a7","paid"=>0,"cat"=>[10505],"storeurl"=>"https=>//itunes.apple.com/cn/app/id902345501?l=zh&mt=8","name"=>"App Name","bundle"=>"yourcompany.com.app","ver"=>"1.2"},"imp"=>[{"id"=>"5cdef32a55397c48b8baeb3cee0c5b5c","bidfloor"=>6000,"instl"=>0,"bidfloorcur"=>"RMB","banner"=>{"w"=>320,"h"=>50,"pos"=>1}}],"device"=>{"os"=>"iOS","model"=>"iPhone5,1","geo"=>{"lon"=>116.4736795,"type"=>1,"lat"=>39.9960702},"osv"=>"7.0.6","js"=>1,"dnt"=>0,"sh"=>1024,"ip"=>"10.23.45.67","s_density"=>2,"connectiontype"=>2,"dpidsha1"=>"7c222fb2927d828af22f592134e8932480637c0d","ua"=>"Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_6 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206","carrier"=>"46000","language"=>"zh","make"=>"Apple","sw"=>768},"user"=>{}}

level  =  0 
def  each_kv  hh
hh.keys.each  do |key|
  val = hh[key]    
  if val.class  == Hash
   # puts "||||| val is #{val} "  
    each_kv val
  end
  if val.class == Fixnum || val.class == Float  || val.class == Array

    puts  "key  #{key } ==>  #{val}  , #{val.class}"
   end
end
end

each_kv(HashObj) 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap