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

bajiudongfeng · 2016年06月23日 · 最后由 u1454813319 回复于 2016年06月27日 · 2235 次阅读

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)

需要 登录 后方可回复, 如果你还没有账号请 注册新账号