Tweaks to scripts/api/common.py to fix JSONDecodeError removal and clean up code.