在 Python 中,可以使用内置的 json
模块来将 JSON 数据转换为字典。
下面是一个简单的示例:
import json
# 假设 json_data 是包含 JSON 数据的字符串
json_data = '{"name": "John", "age": 30, "city": "New York"}'
# 将 JSON 数据转换为字典
data = json.loads(json_data)
print(data) # 输出: {'name': 'John', 'age': 30, 'city': 'New York'}