;; TODO should check for Content-Type
(bind-func ghttp_request_body_as_json
(lambda (request:ghttp_request*)
(let ((err:json_error_t* (zalloc)))
(let ((json (json_loadb (ghttp_get_body request)
(convert (ghttp_get_body_len request))
0
err)))
;; (if (null? json)
;; (printf "JSON error on line %d: %s\n" (tref err 0) (tref err 4)))
(ghttp_request_destroy request)
json))))