合并多个 Slack JSON 文件

合并多个 Slack JSON 文件

我最近导出了一个非常大的 Slack 备份,其中包含服务器中每个频道的每日 JSON 文件。我有一个流程可以手动将这些信息传输到 Discord,但对单个 JSON 文件执行此操作会非常耗时。将文件夹中的所有 JSON 文件合并并为每个频道上传一个会更简单。

每个文件夹的文件结构按日期排列,例如 2021-12-03.json、2021-12-05.json。以下是文件本身的示例结构,它是一个一致的数组:

[
    {
        "bot_id": "B014C6CPY7N",
        "type": "message",
        "text": "User1 has signed up for Associate Membership,Associate Membership with the email <mailto:[email protected]|[email protected]>! Well done team!",
        "user": "U014613HJQJ",
        "ts": "1638698972.000100",
        "team": "T9XQNBRDK",
        "bot_profile": {
            "id": "B014C6CPY7N",
            "app_id": "A024R9PQM",
            "name": "Zapier",
            "icons": {
                "image_36": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_36.png",
                "image_48": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_48.png",
                "image_72": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_72.png"
            },
            "deleted": false,
            "updated": 1590248394,
            "team_id": "T9XQNBRDK"
        }
    },
    {
        "bot_id": "B014C6CPY7N",
        "type": "message",
        "text": "user2 has signed up for Full Membership,Full Membership with the email <mailto:[email protected]|[email protected]>! Well done team!",
        "user": "U014613HJQJ",
        "ts": "1638705446.000100",
        "team": "T9XQNBRDK",
        "bot_profile": {
            "id": "B014C6CPY7N",
            "app_id": "A024R9PQM",
            "name": "Zapier",
            "icons": {
                "image_36": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_36.png",
                "image_48": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_48.png",
                "image_72": "https:\/\/slack-files2.s3-us-west-2.amazonaws.com\/avatars\/2017-06-20\/redacted_2d5e268a3b71c87f969c_72.png"
            },
            "deleted": false,
            "updated": 1590248394,
            "team_id": "T9XQNBRDK"
        }
    }
]

是否有任何软件工具或技巧可以将此类文件合并为一个可以传输的大 JSON?

答案1

通过使用以下 GitHub 项目设法解决了这个问题:

https://github.com/mtacnet/json-merger

克隆了 repo,打开了生成器,它似乎一次可以处理大约 100 个 JSON 文件,然后才像上面 Frank Thomas 的评论那样难以进行解析。

合并的文件导入到我用来在 Slack 和 Discord 之间传输的机器人中(对于任何对该过程感兴趣的人来说,都是 Slackord2)。

相关内容