Remove unnecessary whitespace, fix potential json errors.