如何将多个JSON对象保存到couchdb?或者为什么couchdb不接受JSON中的外括号?

时间:2013-10-18 17:06:23

标签: json couchdb cloudant

我正在尝试将其保存到Cloudant数据库:

[
{
    "_id": "document_one",
    "heynow": [
        {
            "Name": "one",
            "Duration": 2,
            "DurationUnit": "Hours"
        },
        {
            "Name": "two",
            "Duration": 40,
            "DurationUnit": "Minutes"
        }
    ]
},
{
    "_id": "document_two",
    "heynow": [
        {
            "Name": "three",
            "Duration": 2,
            "DurationUnit": "Hours"
        },
        {
            "Name": "four",
            "Duration": 40,
            "DurationUnit": "Minutes"
        }
    ]
}
]

但显然它不喜欢外括号,因为它告诉我:

"error":"bad_request","reason":"Document must be a JSON object"

JSONLint说这是有效的,所以我想我问是否有人知道如何格式化这样可以将其输入Couchdb,因为外括号似乎导致了问题。

1 个答案:

答案 0 :(得分:5)