
我有这个 JSON 文件:
https://drive.google.com/file/d/1zh_fJJNWs9GaPnlLZ459twSubsYkzMi5/view?usp=share_link
一开始看起来很正常,即使使用在线 json 模式验证器 但是,当在本地解析它时,我收到错误。 我用 python、nodejs 和 golang 尝试过,但它不起作用。 我认为它可能有一些隐藏的价值,使得无法解析它
这是完整的解决方案。针对代码添加的注释。
Easily find JSON paths within JSON objects using our intuitive Json Path Finder
30
# read the file as bytes
import chardet
import json
file_path=r"2022_2973.json"
with open (file_path , "rb") as f:
data= f.read() # read file as bytes
file_encoding=chardet.detect(data)['encoding'] # detect the encoding
print(f"file(bytes) encoding:{file_encoding}") # print encoding
json_data = json.loads(data.decode(file_encoding)) # decode the bytes and load the json data
json_data['snaps'][1]输出:
file(bytes) encoding:UTF-16
{'group': 'Slot',
'group_order': 1,
'positions': [{'group': 'Slot',
'position': 'SLWR',以上就是解析 JSON 文件时出错,可能是 JSON 内容的隐藏值的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号