Why does json_agg fail with error "function json_agg(record) does not exist"?
json_agg does not exist in postgres version 9.2 (which is now at end-of-life).  It was introduced in version 9.3.

The HINT does seem to be slightly inappropriate. If no function by that name exists, then no amount of casting the arguments can work.