1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# Begin custom code h = hash h do |key,value| case value when 'Array' h[key] {|e| Object(key) e } when 'Hash' h[key] = Object(key) value end end self h end hash = ActiveSupport json self hash end # The xml has a surrounding class tag (e.g. ship-to), # but the hash has no counterpart (e.g. 'ship_to' => {} ) hash = Hash xml self hash[self] end # End custom code end end |
Pastie