Sha256: 46c37887e6f0794a7dee75df4e410aa6663895029dc9d55cf07268b66f0c491e
Contents?: true
Size: 514 Bytes
Versions: 26
Compression:
Stored size: 514 Bytes
Contents
#!/usr/bin/env ruby require 'json' data = STDIN.read hash = JSON.parse(data) def replace_value(value) if value.is_a?(String) return 'string' end if value.is_a?(Fixnum) return 1 end if value.is_a?(Float) return 1.0 end if value.is_a?(Array) return value.map! do |item| replace_value(item) end end if value.is_a?(Hash) return nest(value) end end def nest(hash) hash.each do |key, value| hash[key] = replace_value(value) end end puts nest(hash).to_json
Version data entries
26 entries across 26 versions & 1 rubygems