Be careful when generating badge json.

Fixes #260.