utils/parsing.js
function toObjectOrUndefined(input) {
    let object = input;
    if (typeof input === 'string') {
        try {
            object = JSON.parse(input);
        }
        catch (e) {}
    }
    if (typeof object === 'object') { return object; }
    return undefined;
}
function toObjectOrUndefined(input) {
    let object = input;
    if (typeof input === 'string') {
        try {
            object = JSON.parse(input);
        }
        catch (e) {}
    }
    if (typeof object === 'object') { return object; }
    return undefined;
}
function toObjectOrUndefined ( input ) { let object = input ; if ( typeof input === 'string' ) { try { object = JSON . parse ( input ) ; } catch ( e ) { } } if ( typeof object === 'object' ) { return object ; } return undefined ; }
Accepts anything and tries to parse into a JSON object. If it fails, returns
undefined.

@param {*} input
@returns {{}|[]|undefined}
Accepts anything and tries to parse into a JSON object . If it fails returns undefined .