【发布时间】:2012-07-30 09:13:12
【问题描述】:
这是一个sample.json文件,如下
{
"name": "Jack (\"Bee\") Nimble",
"format": {
"shape": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"framerate": 24
}
}
在规范文件中,sample.json 文件已打开。
describe Samplespec do
before :all do
@jsonfile = File.open('sample.json').read
@file_json = Samplespec.new(@jsonfile)
end
我已经在 sample.rb 文件中写了这个
require 'json'
def initialize(val)
@parsed_val = JSON.parse(val)
end
这似乎不起作用。请帮忙。谢谢
【问题讨论】:
-
似乎不起作用?你得到什么错误,会发生什么?
-
sample.json 文件按原样显示{ "name": "Jack (\"Bee\") Nimble", "format": { "shape": "rect", "宽度”:1920,“高度”:1080,“隔行”:假,“帧率”:24 } }
标签: ruby json rspec specifications