daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. json = <<ROSHAN
  2. [{"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"}]
  3. ROSHAN
  4.  
  5. array = json.scan(/\{([^}]+)\}/).inject([]) do |n,item|
  6.   n << item[0].scan(/"([^"]+)":"([^"]+)"/).inject({}) do |o,(key,value)|
  7.     o[key] = value
  8.     o
  9.   end
  10. end
  11.  
  12. p array
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top