【问题标题】:Converting BSON file to JSON results in missing content将 BSON 文件转换为 JSON 会导致内容丢失
【发布时间】:2020-05-14 09:33:42
【问题描述】:

我正在尝试将 .bson 文件转换为 .json。我尝试使用 bson 到 json 网站,它们都返回与 python 代码相同的内容。

bson_file = open('fishes.bson', 'rb')
b = bson.loads(bson_file.read())
print(b)

返回:

{'_id': b'5ac88a55eadcdf42044615bb', 'imgurl': 'http://www.fishbase.org/images/thumbnails/jpg/tn_Prweb_u0.jpg', 'rarity': 1, 'id': 0, 'length': 3.1, 'name': 'Aapticheilichthys websteri', 'fishLength': 3.1}

bson 文件是 2.68 MB,所以我认为它不应该只有那个。 bson文件无效吗?我还能如何访问 bson 文件? 我正在使用 python 3.8.1。

Fishes.bsonvirustotal of the bson

【问题讨论】:

    标签: python json bson


    【解决方案1】:

    bson 库确实包含我的答案。

    bson.decode_all(bson_file)
    

    对我来说不起作用,因为显然我的环境被卡住了。但是其他人帮助了我,并运行了代码,这很有效。现在我必须弄清楚我的环境出了什么问题......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多