/**
 * Filename: utils.ts
 * Author: Stevan Bosanac
 * Created Date: 2024-09-17
 *
 * Description:
 * Utils and helper functions.
 *
 * Revision History:
 * 2024-09-17: Initial creation
 *
 */

/**
 * The function `getObjFromJSON` parses a JSON string into an object or returns false if parsing fails.
 * @param {string | null} json - The `json` parameter in the `getObjFromJSON` function is a string that
 * represents a JSON object. It can also be `null` if no JSON object is provided.
 * @returns The `getObjFromJSON` function returns the parsed JSON object if parsing is successful, or
 * `false` if the input JSON is `null` or if an error occurs during parsing.
 */
export const getObjFromJSON = (json: string | null) =>
{
    if (!json) return false;
    try
    {
        return JSON.parse(json);
    }
    catch
    {
        return false;
    }
};
