February 2012
1 post
1 tag
p and pp for json
Great little trick by Peter Cooper (@peterc).
You can use j and jj just as p and pp to print an object as json:
require 'json'
data = { name: "Max Mustermann", tags: ['some', 'tags']}
j data # for simple output
jj data # for really beautiful output
If you wanna learn a few more tricks, visit his ruby trick shots video.