Json builder functions

https://commitfest.postgresql.org/action/patch_view?id=1363
http://archives.postgresql.org/message-id/52E2B072.3060407@dunslane.net