Made function to do JSON output