Escape JSON writes, fixes #52