As things stand, your representation of empty is "{  }" with two spaces between.
If you give this an else clause that writes one space, and drop the leading space from the " }" below, you'll get that down to one space, which looks sensible I think, while still giving spaces around actual content when non-empty.
This is just a suggestion ...