问题描述
{
"id": "3d50809d-d631-4576-925a-7232d9ef9338",
"TrackingId": "3d50809d-d631-4576-925a-7232d9ef9338",
"records": [
{
"measurementTime": {
"value": "2018-04-01 10:00:00.000",
"unit": "datetime"
},
"systolic": {
"value": 114,
"unit": "mm(hg)"
},
"diastolic": {
"value": 88,
"unit": "mm(hg)"
}
}
]
},
{
"id": "c5f3bd10-1959-4407-92cb-6d9548950f2c",
"TrackingId": "c5f3bd10-1959-4407-92cb-6d9548950f2c",
"records": [
{
"measurementTime": {
"value": "2018-04-02 10:00:00.000",
"unit": "datetime"
},
"systolic": {
"value": 122,
"unit": "mm(hg)"
},
"diastolic": {
"value": 91,
"unit": "mm(hg)"
}
}
]
}
我正在尝试在具有这种示例格式的Azure Docuemnt DB中查询文档.(请不要尝试在查询中验证JSON或属性名称,我只是提供了一个剥离的版本以了解层次结构)
I am trying to querying documents in Azure Docuemnt DB having this sample format. (please don't try to validate JSON or property names in query, i am giving just a stripped of version to understand hierarchy)
我已经成功查询了一些属性,但是尝试通过下面提到的查询在systolic-> value或diastolic-> value下获取整数值时出现错误.
I am successfully querying some properties, but i am getting error when trying to fetch the integer value under systolic--> value or diastolic--> value with the query mentioned below.
成功查询:
SELECT
c.id,
c.TrackingId,
c.records[0].measurementTime["value"]
失败查询:
SELECT
c.id,
c..TrackingId,
c.records[0].measurementTime["value"],
c.records[0].systolic["value"],
c.records[0].diastolic["value"]
["value"]的关键字用法适用于测量时间,但不适用于收缩压或舒张压
the keyword usage of ["value"] is working for measuremenTtime but not working for systolic or diastolic
错误详细信息:
消息:对象创建错误,属性名称'值'被多次指定.
Message : "Object creation error, property name 'value' specified more than once.
代码:400
严重性:错误
推荐答案
Kailash Ravuri,实际上,您的问题与字段名称或字段类型无关.根据您的查询sql,您的结果数据具有3个名为'value'
的字段,这是不允许的.您只需要向3个字段添加别名即可,一切正常.
Kailash Ravuri, in fact, your issue is not related to field name or field type. Based on your query sql, your result data have 3 fields named 'value'
,it's not allowed. You just need to add an alias to 3 fields and everything will be ok.
SELECT
c.id,
c.TrackingId,
c.records[0].measurementTime["value"] as measurementTimeValue,
c.records[0].systolic["value"] as systolicValue,
c.records[0].diastolic["value"] as diastolicValue FROM c
希望它对您有帮助.
这篇关于Document DB SQL Api-无法查询名称为'value'并且其值为整数的json属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!