generator: Escape Object key names correctly

Also fix empty keys, which are now encoded properly.

https://bugzilla.gnome.org/show_bug.cgi?id=727593