Cleaning up JSON formatting code