Module: Json2Json

Defined in:
lib/json2json.rb

Class Method Summary collapse

Class Method Details

.transform(original, transformation_template) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/json2json.rb', line 5

def self.transform(original, transformation_template)
  t = transformation_template
  Hash[t.map{|k,v|
      [k, v.is_a?(Hash) ? self.transform(original, t[k]) : JsonPath.new(v).on(original.to_json)[0]]
    }]

end