在 Python 中,可以使用 json
模块来加载 JSON 数据。你可以使用 json.load()
方法来从文件中加载 JSON 数据,或者使用 json.loads()
方法来将字符串转换为 JSON 对象。
例如:
import json
# 加载 JSON 文件
with open('data.json', 'r') as f:
data = json.load(f)
# 将字符串转换为 JSON 对象
json_string = '{"name": "John", "age": 30, "city": "New York"}'
data = j