对于以下JSON文件,我很难生成命令
这就是我的JSON文件的外观,
"Patient":{
"Name":{
"Patient First Name":"James",
"Patient Middle Name":"Adam",
"Patient Last Name":"Manchester"
},
"Unique ID":163983,
"Demographics":{
"Sex":"M",
"Birthdate":"7/24/1940"
},
"IntakeCriteria":{
"DmDxDate":"8/25/2012",
"InitialHgbA1c":8.1,
"Comorbidity":["Diabetes Mellitus","CHF","DVT"]
},
"Labs":{
"LDLCholesterol":{
"LDLResultDate":"5/6/2013",
"LDLLevel":200
},
"SerumCreatinine":{
"CreatinineResultDate":"11/1/2016",
"CreatinineLevel":0.9
}
},
"CareLocation":{
"Facility Name":"East Side Clinic",
"Facility Contact Name":"Mary Silverman",
"Facility Contact Phone":"618-348-1891"
}
}
}
我需要使用以下字段来准备查询:
Patient Unique ID number.
Patient First Name.
Patient Last Name.
Lab Test Date.
HgbA1c Level.
LDL Level.
Creatinine Level.
我尝试了此结果,因此没有结果
jq - r’[.Patient.UniqueID, .Patient.Name.FirstName, .Patient.Name.LastName, .Patient.Labs.LDLCholesterol.LabResultDate, .Patient.IntakeCriteria.InitialHgbA1c, .Patient.Labs.LDLCholesterol.LDLLevel, .Patient.Labs.SerumCreatine.CreatineLevel] | @csv’ data.json > csvtest.out
This is how my json file looks
"Patient":{
"Name":{
"Patient First Name":"James",
"Patient Middle Name":"Adam",
"Patient Last Name":"Manchester"
},
"Unique ID":163983,
"Demographics":{
"Sex":"M",
"Birthdate":"7/24/1940"
},
"IntakeCriteria":{
"DmDxDate":"8/25/2012",
"InitialHgbA1c":8.1,
"Comorbidity":["Diabetes Mellitus","CHF","DVT"]
},
"Labs":{
"LDLCholesterol":{
"LDLResultDate":"5/6/2013",
"LDLLevel":200
},
"SerumCreatinine":{
"CreatinineResultDate":"11/1/2016",
"CreatinineLevel":0.9
}
},
"CareLocation":{
"Facility Name":"East Side Clinic",
"Facility Contact Name":"Mary Silverman",
"Facility Contact Phone":"618-348-1891"
}
}
}
I need to prepare a query using the following fields:
Patient Unique ID number.
Patient First Name.
Patient Last Name.
Lab Test Date.
HgbA1c Level.
LDL Level.
Creatinine Level.
I tried this resulting in no result
jq - r’[.Patient.UniqueID, .Patient.Name.FirstName, .Patient.Name.LastName, .Patient.Labs.LDLCholesterol.LabResultDate, .Patient.IntakeCriteria.InitialHgbA1c, .Patient.Labs.LDLCholesterol.LDLLevel, .Patient.Labs.SerumCreatine.CreatineLevel] | @csv’ data.json > csvtest.out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当使用您必须按照JSON文件中的使用完全提供字段名称。另外,如果它们包含特殊字符,例如白色空间(或以数字开头),请用双引号包围以澄清:
demo
要稍微缩短过滤器,您也可以使用带管的子滤光器
|
在与括号进行分组()
:When using object identifiers, you have to provide the field names exactly as used in the JSON file. Also, if they contain special characters such as white spaces (or start with a digit), surround them with double quotes for clarification:
Demo
To shorten your filter a bit, you may also group together some of the paths sharing common parents using subfilters with pipes
|
within a grouping with parentheses()
:Demo