import json file to couch db-

前端 未结 7 1877
猫巷女王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:46

    That JSON object will not be accepted by CouchDB. To store all the data with a single server request use:

    {
      "people": 
       [
          {
            "name":"bob",
            "hi":"hello"
          },
          { 
            "name":"hello",
            "hi":"bye"
          }
       ]
    }
    

    Alternatively, submit a different CouchDB request for each row.

    Import the file into CouchDB from the command-line using cURL:

    curl -vX POST https://user:pass@127.0.0.1:1234/database \
      -d @- -# -o output -H "Content-Type: application/json" < file.json
    

提交回复
热议问题