The JSON string to parse
If true, parsing errors will be logged to console (default: false)
The parsed object of type T (default: any), or null if parsing fails or input is empty
// Basic usage without type
const data = SafeJSONParse('{"name": "test"}');
// With type parameter
interface User { name: string; age: number; }
const user = SafeJSONParse<User>('{"name": "John", "age": 30}', true);
// Invalid JSON returns null
const result = SafeJSONParse('invalid json', true); // logs error, returns null
Simple wrapper method to JSON.parse that catches any errors and optionally logs them to the console. This method is useful when you want to parse JSON but don't want to crash the application if the JSON is invalid.