我想通过ruby导出类似sample.json的JSON文件。 (我会上传json.file到S3)如何通过ruby导出json文件?
我期待以下的方式,但是它需要准备json文件。有没有办法在Ruby上导出json文件?
File.open("sample.json", "w") do |f|
f.write(sample_data.to_json)
end
sample.json
{
"asset_ids": [
"this is id",
],
"contract_url": "http://hoge.com/",
"name_short": "Hoge",
"name": "HogeHoge",
"issuer": "Fuga",
"description": "",
"description_mime": "text/x-markdown; charset=UTF-8",
"type": "Currency",
"divisibility": 1,
"link_to_website": false,
"version": "1.0"
}
什么是错的,你正在做的方式? – shivam
检查此问题http://stackoverflow.com/questions/5507512/write-to-json-file-in-correct-format-ruby –
亲爱的Gami 谢谢!我会检查它。 – lalala