我有一个列表(见下文),我希望将列表中包含Unicode字符(例如,'①'、'②'、'')的任何元素作为'category' JSON元素内的键/值对,并将列表中每个Unicode元素之间的以下元素作为'codes' JSON嵌套分组内的键/值对。
我有什么列表:
['①', 'Type of Care']
['SA', 'Substance use treatment']
['DT', 'Detoxification']
['HH', 'Transitional housing, halfway house, or sober home']
['SUMH', 'Treatment for co-occurring serious mental health illness/serious emotional disturbance and substance use disorders']
['②', 'Telemedicine']
['TELE', 'Telemedicine/telehealth']
['③', 'Service Settings (e.g., Outpatient, Residential, Inpatient, etc.)']
['HI', 'Hospital inpatient']
['OP', 'Outpatient']
['RES', 'Residential']
['HID', 'Hospital inpatient detoxification']
['HIT', 'Hospital inpatient treatment']
['OD', 'Outpatient detoxification']
['ODT', 'Outpatient day treatment or partial hospitalization']
['OIT', 'Intensive outpatient treatment']
['ORT', 'Regular outpatient treatment']
['RD', 'Residential detoxification']
['RL', 'Long-term residential']
['RS', 'Short-term residential']
['⑰', 'Assessment/Pre-treatment']
['CMHA', 'Comprehensive mental health assessment']
['CSAA', 'Comprehensive substance use assessment']
['ISC', 'Interim services for clients']
['OPC', 'Outreach to persons in the community']
['㉖', 'Facility Smoking Policy']
['SMON', 'Smoking not permitted']
['SMOP', 'Smoking permitted without restriction']
['SMPD', 'Smoking permitted in designated area']
我想创建的键/值对JSON:
{
"codekey": [
{
"category": {
"key": "①",
"value": "Type of Care"
},
"codes": [
{
"key": "SA",
"value": "Substance use treatment"
},
{
"key": "SA",
"value": "Substance use treatment"
},
{
"key": "DT",
"value": "Detoxification"
},
{
"key": "HH",
"value": "Transitional housing, halfway house, or sober home"
},
{
"key": "SUMH",
"value": "Treatment for co-occurring serious mental health illness/serious emotional disturbance and substance use disorders"
}
]
},
{
"category": {
"key": "②",
"value": "Telemedicine"
},
"codes": [
{
"key": "TELE",
"value": "Telemedicine/telehealth"
}
]
},
{
"category": {
"key": "③",
"value": "Service Settings (e.g., Outpatient, Residential, Inpatient, etc.)"
},
"codes": [
{
"key": "HI",
"value": "Hospital inpatient"
},
{
"key": "OP",
"value": "Outpatient"
},
{
"key": "RES",
"value": "Residential"
},
{
"key": "HID",
"value": "Hospital inpatient detoxification"
},
{
"key": "HIT",
"value": "Hospital inpatient treatment"
},
{
"key": "OD",
"value": "Outpatient detoxification"
},
{
"key": "ODT",
"value": "Outpatient day treatment or partial hospitalization"
},
{
"key": "OIT",
"value": "Intensive outpatient treatment"
},
{
"key": "ORT",
"value": "Regular outpatient treatment"
},
{
"key": "RD",
"value": "Residential detoxification"
},
{
"key": "RL",
"value": "Long-term residential"
},
{
"key": "RS",
"value": "Short-term residential"
}
]
},
{
"category": {
"key": "⑰",
"value": "Assessment/Pre-treatment"
},
"codes": [
{
"key": "CMHA",
"value": "Comprehensive mental health assessment"
},
{
"key": "CSAA",
"value": "Comprehensive substance use assessment"
},
{
"key": "ISC",
"value": "Interim services for clients"
},
{
"key": "OPC",
"value": "Outreach to persons in the community"
}
]
},
{
"category": {
"key": "㉖",
"value": "Facility Smoking Policy"
},
"codes": [
{
"key": "SMON",
"value": "Smoking not permitted"
},
{
"key": "SMOP",
"value": "Smoking permitted without restriction"
},
{
"key": "SMPD",
"value": "Smoking permitted in designated area"
}
]
}
]
}
1条答案
按热度按时间deyfvvtc1#
希望下面的代码能有所帮助--这段代码迭代一个名为
src_list
的变量中的项,并使用字典创建一个JSON输出,如您所述。