如何在python中遍历此json?我想访问标记,并基于此在文本中应用html格式标记。我想根据标记中提供的起点和终点在文本中添加标签。
{
"content": [{
"markups": [],
"contentType": "MEDIA",
"text": "You will be pleasantly surprised to see snow-capped mountains surrounding you in all directions!",
"media": {
"path": "https://cdn-images-1.medium.com/1*wwvQhdsEA_X4E5GG8JYSsQ.jpeg",
"mediaType": "IMAGE",
"height": 2389,
"width": 5999
}
},
{
"markups": [],
"contentType": "TITLE",
"text": "Uncharted territories: Parvati Valley, Kalga, Kheerganga Trek"
},
{
"markups": [{
"type": "ITALICS",
"start": 134,
"end": 145
}],
"contentType": "BODY",
"text": "If you have never wandered in the woods"
}
]
}
答案 0 :(得分:0)
您提供的JSON无效。
有效的JSON字符串可以转换为嵌套字典,如下所示:
import json
json_dict = json.loads(json_string)