Fix JSON format writing

Fixes #565

Signed-off-by: Michal Čihař <michal@cihar.com>