MongoDB JSON输入意外结束,使用python进行废弃

2024-04-29 12:25:00 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我刮擦Fanfirfiction.net网站获取故事数据,并返回字典。我将字典转储到我的json文件中,并确保它是有效的,然后当我尝试将json文件导入MongoDB时,它会以json输入的意外结尾返回。我在谷歌上搜了一下,似乎没人知道答案。我将附加一个链接到我试图导入的整个数据文件,并有多个类似的文件,我需要导入。还附上了我必须导入的原始JSON:

{
    "id": "4391921",
    "canon": "Supernatural",
    "author_id": 3240,
    "title": "Light of Day, Dark of Moon",
    "lang": "English",
    "published": 1215966904,
    "chapter_names": [
        "Light of Day, Dark of Moon"
    ],
    "genres": [
        "Drama",
        "Family"
    ],
    "canon_type": [
        "TV Shows"
    ],
    "rated": "Fiction  T",
    "num_words": 3441,
    "num_reviews": 38,
    "num_favs": 79,
    "num_follows": 11,
    "status": "Complete"
},
{
    "id": "4391909",
    "canon": "Supernatural",
    "author_id": 3240,
    "title": "A Year and a Day",
    "lang": "English",
    "published": 1215966494,
    "chapter_names": [
        "A Year and a Day"
    ],
    "genres": [
        "Drama",
        "Hurt/Comfort"
    ],
    "canon_type": [
        "TV Shows"
    ],
    "rated": "Fiction  M",
    "num_words": 32830,
    "num_reviews": 10,
    "num_favs": 46,
    "num_follows": 3,
    "status": "Complete"
},

https://github.com/ethanbreck/fanfiction-api-scraper/tree/master/data/user_write


Tags: 文件ofidjsonlang字典titlenum