Avoids errors in trailing comma handling, broken indentation and improper escaping that is common when building JSON by manually concatenating strings.