Fix generating JSON from all-empty, all-optionals

If a buf contains only optionals (ie, the fields are all Options) AND all those fields are empty, the resulting JSON object will be malformed. Since nothing is printed in the object, the opening bracket will be eaten by the [sb.length -= 1].
This hopefully fixes that.
(I noticed that I accidentally ran my cleanup script on this file too, hence the removed braces and semicolons. The important change of course is on line 397. Sorry about that...)