From: Marko Anastasov Date: 2007-11-24T20:10:04+09:00 Subject: Re: Parsing nested JSON data On Nov 24, 8:05 am, 7stud -- wrote: > 7stud -- wrote: > > There's no documentation anywhere, and after I installed > > it, I couldn't even require it into a program without error. > > Look how easy it is with the json gem: > > require 'rubygems' > require 'json' > > str = '[ > {"u":"http://...html","d":"some title","t":["ruby"]}, > {"u":"http://....org/","d":"another > title","t":["ruby","json","library"]} > ]' > > arr = JSON.parse(str) > p arr > puts > > target_hash = arr[1] > target_hash.each do |key, val| > if key == 't' > val.each {|elmt| puts elmt} > end > end > > --output:-- > [{"d"=>"some title", "t"=>["ruby"], "u"=>"http://...html"}, > {"d"=>"another title", "t"=>["ruby", "json", "library"], > "u"=>"http://....org/"}] > > ruby > json > library > -- > Posted viahttp://www.ruby-forum.com/. Thanks a lot 7stud. I didn't realize that each val (as in your last code snippet) is an array.