Method: JsonHelper#parse_json
- Defined in:
- lib/common/json_helper.rb
#parse_json(str) ⇒ Object Also known as: from_json, decode_json
功能:
封装对JSON的解析
参数解释:
-
str JSON字符串
Example:
Example #1:
puts ({"fs"=>"非技术","xv"=>[3,4,{3=>4},"飞拉萨"],4=>5}).to_json
#=> {"fs":"非技术","xv":[3,4,{"3":4},"飞拉萨"],"4":5}
h = parse_json('{"fjsl":"方式来快递费",243:42,"ha":[3,4,"方式来开发","fs"],"非技术":"附件"}')
p h
#=> {"fjsl"=>"方式来快递费", "243"=>42, "ha"=>[3, 4, "方式来开发", "fs"], "非技术"=>"附件"}
28 29 30 |
# File 'lib/common/json_helper.rb', line 28 def parse_json(str) JSON.parse(str) end |