generator: Escape Object key names correctly

Also fix empty keys, which are now encoded properly.

https://bugzilla.gnome.org/show_bug.cgi?id=727593
generator: Escape the control characters correctly

Escaping these as octals is out of the JSON spec completely,
so roll our own string encoder.

https://bugzilla.gnome.org/show_bug.cgi?id=730425
generator: Add tests for updated string escaping routine

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