Fix json generation bug

If a message consists entirely of optional fields and none of them are set then the message gets serialized to Json as `{` instead of `{}`.
+1, why the change? It seems unrelated to your bug fix.