Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p={'x': 1534804991, 'y': 0.1}
- p={:x=>1534804991, :y=>0.1}
- p.gsub(''x'',':x=>')
- p.gsub("'x'",":x=>")
- p.sub!(w/xw/, ":x=>")
- hash = {'x': 1534804991, 'y': 0.1}
- p hash.transform_keys(&:to_sym) # {:x=>1534804991, :y=>0.1}
- hash.each_with_object({}) { |(k, v), h| h[k] = v }
- p = File.read('xxx.json')
- # => "{'x': 1534804991, 'y': 0.1}"
- puts p
- # => {'x': 1534804991, 'y': 0.1}
- puts p.gsub(/'(w+)': /, ':1=>')
- # => {:x=>1534804991, :y=>0.1}
Add Comment
Please, Sign In to add comment