新手问题 [已解决]字符串转换成 hash

bajiudongfeng · June 23, 2016 · Last by u1454813319 replied at June 27, 2016 · 2235 hits

w = "{'response':{'id':'19999','period':'5','fieldList':[{'date':'2016-06-23','time':'00:01:07'},{'date':'2016-06-23','time':'00:06:07'}]}}"

uri = URI(price_api) price_data = Net::HTTP.get(uri) 使用如上方法获取 api 的结果是一个字符串 如上字符串如何才能转换成 hash?

require 'safe_yaml' YAML.load(w)

MultiJson.load(price_data)

You need to Sign in before reply, if you don't have an account, please Sign up first.