import json file to couch db-

前端 未结 7 1844
猫巷女王i
猫巷女王i 2020-12-14 04:27

If I have a json file that looks something like this:

{\"name\":\"bob\",\"hi\":\"hello\"}
{\"name\":\"hello\",\"hi\":\"bye\"}

Is there an o

相关标签:
7条回答
  • 2020-12-14 04:58

    Yes, this is not valid JSON ...

    To import JSON-Objects I use curl (http://curl.haxx.se):

    curl -X PUT -d @my.json http://admin:secret@127.0.0.1:5984/db_name/doc_id
    

    where my.json is a file the JSON-Object is in. Of course you can put your JSON-Object directly into couchdb (without a file) as well:

    curl -X PUT -d '{"name":"bob","hi":"hello"}' http://admin:secret@127.0.0.1:5984/db_name/doc_id
    

    If you do not have a doc_id, you can ask couchdb for it:

    curl -X GET http://127.0.0.1:5984/_uuids?count=1
    
    0 讨论(0)
提交回复
热议问题