code: 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;
  }
docs: Accepts anything and tries to parse into a JSON object. If it fails, returns
  undefined.
  
  @param {*} input
  @returns {{}|[]|undefined}