首页 > 代码库 > json 转 hash(MultiJson)

json 转 hash(MultiJson)

require ‘multi_json‘MultiJson.load(‘{"abc":"def"}‘) #=> {"abc" => "def"}MultiJson.load(‘{"abc":"def"}‘, :symbolize_keys => true) #=> {:abc => "def"}MultiJson.dump({:abc => ‘def‘}) # convert Ruby back to JSONMultiJson.dump({:abc => ‘def‘}, :pretty => true) # encoded in a pretty form (if supported by the coder)
MultiJson.load(MultiJson.dump({:abc => ‘def‘}),:symbolize_keys => true)