如何在CouchDB中获取“mycc \ u0000a”等URL不安全密钥的值?

时间:2017-09-15 10:59:11

标签: couchdb url-encoding couchbase-view

我有一个带有文档的数据库'myc',如

{
  "total_rows": 3,
  "offset": 0,
  "rows": [{
    "id": "lscc\u0000mycc",
    "key": "lscc\u0000mycc",
    "value": {
      "rev": "1-35f379c3ea35ef0077b595923bf36151"
    }
  }, {
    "id": "mycc\u0000a",
    "key": "mycc\u0000a",
    "value": {
      "rev": "2-f3049e0b19f6969f01671889c8b1456f"
    }
  }, {
    "id": "statedb_savepoint",
    "key": "statedb_savepoint",
    "value": {
      "rev": "3-62ba0d88e905ef321c85c542bec7bd15"
    }
  }]
}

我需要获取存储在密钥/ ID中的值,例如lscc\u0000myccmycc\u0000a

如果密钥是网址安全的,我们只需拨打http://localhost:5984/myc/statedb_savepoint即可。如何使用GET请求访问相同的内容?

1 个答案:

答案 0 :(得分:0)

您必须对ID(%5C)中的反斜杠进行网址编码:

http://localhost:5984/myc/lscc%5Cu0000mycc

http://localhost:5984/myc/mycc%5Cu0000a