/**
 * @since Last modified: 2023-12-29 05:34:27
 * @function strToJson
 * @param {string} str  - Json string.
 * @returns {Object|{}} - Return a json.
 * @see {@link https://codepen.io/axui/pen/OJdQvrg|demo @ codepen}
 * @example
 * ax.strToJson('a:0,b:1');
 * <!--return {a:0,b:1}-->
 */
'use strict';
const strToJson = (str: string) => {
    if (str) {
        str = str.trim();
        try {
            !str.startsWith('{') ? str = `{${str}}` : null;
            return new Function('return ' + str)();
        } catch (e) {
            return {};
        }
    }
    else {
        return {};
    }
}
export default strToJson;
