
我最近匯出了一個非常大的 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
克隆了存儲庫,打開了生成器,它似乎一次性處理了大約 100 個 JSON 文件,然後按照上面 Frank Thomas 的評論進行解析。
合併的檔案匯入到我用來在 Slack 和 Discord 之間傳輸的機器人(Slackord2 對於任何對此過程感興趣的人)。