属性名称中可以使用哪些字符? -FIWARE猎户座

时间:2019-02-01 22:42:42

标签: fiware fiware-orion

我想了解有关可以在属性名称中使用的字符集和字符代码的详细信息。我试图创建一个实体,其属性名称为“日本语”。对于NGSIv1,我可以创建它,但是对于NGSIv2,则不能创建它。

  • 对于NGSIv1 API,

请求:

DefaultState

响应:

(curl localhost:1026/v1/updateContext -sS --header 'Content-Type: application/json' \
        --header 'Accept: application/json' -d @- <<EOF) | jq .
{
  "contextElements": [
    {
      "type": "Test",
      "isPattern": "false",
      "id": "Testv1",
      "attributes": [
        {
          "name": "japanese",
          "type": "Integer",
          "value": "1"
        },
        {
          "name": "日本語",
          "type": "Integer",
          "value": "2"
        }
      ]
    }
  ],
  "updateAction": "APPEND"
}
EOF
  • 对于NGSIv2 API,

请求:

{
  "contextResponses": [
    {
      "contextElement": {
        "type": "Test",
        "isPattern": "false",
        "id": "Testv1",
        "attributes": [
          {
            "name": "japanese",
            "type": "Integer",
            "value": ""
          },
          {
            "name": "日本語",
            "type": "Integer",
            "value": ""
          }
        ]
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

响应:

(curl localhost:1026/v2/entities -s -S -H 'Content-Type: application/json' \
-d @- <<EOF) | jq .
{
  "id": "Test1",
  "type": "Test",
  "japanese": {
    "value": 1,
    "type": "Integer"
  },
  "日本語": {
    "value": 2,
    "type": "Integer"
  }
}
EOF

1 个答案:

答案 0 :(得分:1)

NGSIv2 specification中有关允许的字符的相关部分为“字段语法限制”,“属性名称限制”和“元数据名称限制”。

尤其是与此问题有关的主题:

  

允许的字符是纯ASCII码集中的字符,但以下字符除外:控制字符,空格,&?/#

也请注意

  

除了上述规则外,给定的NGSIv2服务器实现可以在这些或其他领域添加其他语法限制,例如,以避免跨脚本注入攻击。

,对于Orion,它被指定为其文档here的一部分。