JSON and XML export logic.