The string to process, which may contain JSON in various formats
A formatted JSON string if valid JSON is found, otherwise null
// Double-escaped JSON
CleanJSON('{\\"name\\": \\"test\\", \\"value\\": 123}')
// Returns: '{\n "name": "test",\n "value": 123\n}'
Cleans and extracts valid JSON from various input formats including double-escaped strings, strings with embedded JSON, and markdown code blocks.
This function handles multiple scenarios in the following priority order: