Skip to content

Instantly share code, notes, and snippets.

@pmn4
pmn4 / service_response_object.rb
Last active August 29, 2015 14:13
Ruby Classes as Hash Wrappers (for faster serialization)
#!/usr/bin/env ruby
# More often than not at @RTR_tech, our ruby layer is a pass-through from our
# services to our client application. In those cases, it doesn't make much
# sense to parse the JSON string.
#
# Other times, however, we want to work with the objects that come back, so
# like good ruby developers, we create classes which reflect the data we
# expect, but as an intermittant step, we convert the JSON to a Hash, which
# we convert to an object.
@pmn4
pmn4 / JSON.stringify
Created April 10, 2014 14:45
JSON.stringify takes Parameters
var o = {
a: 1,
b: 2,
c: 3,
d: {
a: 5,
b: 6
}
};