json code from http://git.ozlabs.org/?p=ccan;a=tree;f=ccan/json;hb=HEAD