adding dynamic to_json function to models