开发者

Save Json object to Couchdb

开发者 https://www.devze.com 2023-03-26 00:30 出处:网络
I would like to write a ruby script that will save the Json object stor开发者_开发百科ed in a file to Couchdb.

I would like to write a ruby script that will save the Json object stor开发者_开发百科ed in a file to Couchdb.

A code snippet to exmplain this would be very handy.


Here is all you want: Getting started with Ruby


I wrote a small script like this which did the trick for me!

require 'json' require 'rest_client' require 'couchrest' require 'pp'

json = File.read('file.json')
doc = JSON.parse(json)
CouchRest.post('http://localhost:5984/db/',doc)

pp doc
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号