api: generate JSON response objects at startup, change util.JSONAPIFunc to (int, []byte, error) return