JSON formatting
Factor out isFunction