import json5 import json def correct_malformed_json(json_string): try: # Use json5 to parse the more flexible JSON format parsed_json = json5.loads(json_string) # Reformat and pretty-print the JSON using json.dumps formatted_json = json.dumps(parsed_json, indent=4) return formatted_json except json5.JSONDecodeError as e: return f"Error: {e}" # Example usage with a malformed JSON string malformed_json = '{"greeting": ["Good afternoon Tony", "Let me introduce our guest""]}' print(correct_malformed_json(malformed_json))