这是一个 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
这似乎不起作用。请帮忙。谢谢