Inspired by jQuery. See https://github.com/jquery/jquery/blob/master/src/data.js
function getValue(value) {
  var data = value,
      result = value;

  if (typeof data === 'string') {
    try {
      if (!data || data === 'true') {
        result = true;
      } else if (data === 'false') {
        result = false;
      } else if (data === 'null') {
        result = null;
      } else if (+data + '' === data) {
        result = +data;
      } else {
        result = rbrace.test(data) ? JSON.parse(data) : data;
      }
    } catch (error) {}
  }
  return result;
}