我有一个json文件,如下所示:
[
{
"id": "john",
"title": "tech",
"date": "2020/1/1",
"shift": "DAYS"
},
{
"id": "tom",
"title": "tech",
"date": "2021/5/5",
"shift": "NIGHT"
}
]
我需要根据这些信息重新创建另一个JSON文件。例如:
如果班次==夜间:
shiftHourStart=22:00:00
班次结束=06:00:00
所以输出应该是这样的:
[
{
"id": "john",
"title": "tech",
"shiftHourStart" = "22:00:00",
"shiftHourEnd" = "06:00:00"
"shift": "NIGHT"
},
{
"id": "tom",
"title": "tech",
"date": "2021/5/5",
"shiftHourStart" = "06:00:00",
"shiftHourEnd" = "15:00:00",
"shift": "DAY"
}
]
您可以使用
dict.update
使用以下命令:
为您的案例编辑: 如果json文件是
".\\file.json"
,那么相关问题 更多 >
编程相关推荐