Contents

Sort Scrapbox JSON (Auto Project Backup) by title for git

Contents

Pages in Scrapbox can be exported in JSON format as “Auto Project Backup” (https://scrapbox.io/projects/PROJECT_NAME/settings/backup). When managing it with git, on every time exporting and git-adding, diff will be too large because the order of pages is totally changed. It’s solved by sorting by title:

1
2
3
4
cp ~/Downloads/wataash_20060102_150405.json ./scrapbox.json
git diff ./scrapbox.json  # too large diff!
jq <~/Downloads/wataash_20060102_150405.json '.pages = (.pages | sort_by(.title))' > ./scrapbox.json
git diff ./scrapbox.json  # good diff