Thanks to Lisa for her tip w/r/t migrating from bearblog to mataroa. She suggested using the core utility csplit to split the archive into individual files instead of the commercial program I found. It took some tinkering, but I figured out how to make it work.
csplit can only split a file at lines, not at a specific character. So the first thing you need to do is use sed to make sure the ending delimiter, }, is on its own line. Here's the command:
sed 's/\},/\n\}\n/g' post_export.json > post_export2.json
This will remove the superfluous comma and split the JSON file into 2 lines each: one line for the post, and one line for the }. The new data will be saved as post_export2.json.
Now you can use csplit to split this into multiple files:
csplit --keep-files --prefix=post --digits=3 post_export2.json $'/\}/+1' '{*}'
This will create post001, post002 etc. (the file extension isn't actually necessary for the import process.) Again, if you have a 2-digit number of posts, change it to --digits=2.
Your original post_export.json was an array, and thus contained inside [square brackets]. Open post001 and remove the [, then save the file. Do the same with your last post and ].
Now, simply run the script from the previous post with the new filename format:
for i in {000..999} do json="@post"$i curl -X POST \ -H 'Authorization: Bearer <api_key>' \ -d $json \ https://mataroa.blog/api/posts/ sleep 5 done
You can't import your post slugs
Mea culpa on this one: I assumed that the mataroa API would let you set a slug for a post, but it doesn't. It just automatically converts the title attribute into a slug. This has led to posts with some extremely unwieldy URLs, which is kind of funny. I figure most people don't write posts with extremely unwieldy titles to begin with, but if you do, you can always change the slug manually after the fact.
So, when you're converting your bearblog archive to JSON, don't worry about slug. title, published date and content are all you need.
