Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- json = <<ROSHAN
- [{"permalink":"http:\/\/icanhascheezburger.com\/2010\/06\/04\/funny-pictures-for-all-to-see\/","title":"..and after cruely","url":"http:\/\/icanhascheezburger.files.wordpress.com\/2010\/05\/funny-pictures-cat-tortured-mouse.jpg"},{"permalink":"http:\/\/icanhascheezburger.com\/2010\/06\/04\/funny-pictures-survived-the-experiment\/","title":"Schrodinger’s cat survived the","url":"http:\/\/icanhascheezburger.files.wordpress.com\/2010\/05\/funny-pictures-cat-survived-experiment.jpg"},{"permalink":"http:\/\/icanhascheezburger.com\/2010\/06\/04\/funny-pictures-knows-youre-in-there\/","title":"Census kitteh knows you’re in there.","url":"http:\/\/icanhascheezburger.files.wordpress.com\/2010\/05\/funny-pictures-cat-takes-census.jpg"},{"permalink":"http:\/\/icanhascheezburger.com\/2010\/06\/03\/funny-pictures-a-chick-magnet\/","title":"Basement Cat’s Minion traded his soul","url":"http:\/\/icanhascheezburger.files.wordpress.com\/2010\/05\/funny-pictures-cat-is-chick-magnet.jpg"},{"permalink":"http:\/\/icanhascheezburger.com\/2010\/06\/03\/funny-pictures-turnd-me-down\/","title":"Teh modeling agency","url":"http:\/\/icanhascheezburger.files.wordpress.com\/2010\/05\/funny-pictures-cat-will-not-be-model.jpg"}]
- ROSHAN
- array = json.scan(/\{([^}]+)\}/).inject([]) do |n,item|
- n << item[0].scan(/"([^"]+)":"([^"]+)"/).inject({}) do |o,(key,value)|
- o[key] = value
- o
- end
- end
- p array
Add Comment
Please, Sign In to add comment