过去几天我一直在试验猎户座,过了一会儿,我按照我的意图开始工作.
我遇到了意想不到的烦恼,其中给定实体上下文的字符串属性将无法注册.
例:
http POST [my_orion_server_url]:1026/v1/updateContext < create_push.json
create_push.json的位置是:
{
"contextElements": [
{
"type": "Push",
"isPattern": "false",
"id": "Push1",
"attributes": [
{
"name": "message",
"type": "string",
"value": "this is a test)"
}
]
}
],
"updateAction": "APPEND"
}
服务器回复:
HTTP/1.1 200 OK
Content-Length: 129
Content-Type: application/json
Date: Thu, 19 Nov 2015 11:47:03 GMT
{
"errorCode": {
"code": "400",
"details": "Illegal value for JSON field",
"reasonPhrase": "Bad Request"
}
}
另一方面,如果我删除括号,一切都按预期工作:
json文件:
{
"contextElements": [
{
"type": "Push",
"isPattern": "false",
"id": "Push1",
"attributes": [
{
"name": "message",
"type": "string",
"value": "this is a test"
}
]
}
],
"updateAction": "APPEND"
}
服务器响应:
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "message",
"type": "string",
"value": ""
}
],
"id": "Push1",
"isPattern": "false",
"type": "Push"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
这是故意还是错误?
我可以克服用其他东西编码括号然后在接收时解码的问题,但是能够直接发送与实体的括号将更平滑且更不烦人.
最佳答案 这是预期的行为.请看看 Orion documentation.