index.js
function html(obj, indents) {
  indents = indents || 1;

  function indent() {
    return Array(indents).join('  ');
  }

  if ('string' == typeof obj) {
    var str = escape(obj);
    if (urlRegex().test(obj)) {
      str = '<a href="' + str + '">' + str + '</a>';
    }
    return span('string value', '"' + str + '"');
  }

  if ('number' == typeof obj) {
    return span('number', obj);
  }

  if ('boolean' == typeof obj) {
    return span('boolean', obj);
  }

  if (null === obj) {
    return span('null', 'null');
  }

  var buf;

  if (Array.isArray(obj)) {
    ++indents;

    buf = '[\n' + obj.map(function(val){
      return indent() + html(val, indents);
    }).join(',\n');

    --indents;
    buf += '\n' + indent() + ']';
    return buf;
  }

  buf = '{';
  var keys = Object.keys(obj);
  var len = keys.length;
  if (len) buf += '\n';

  ++indents;
  buf += keys.map(function(key){
    var val = obj[key];
    key = '"' + key + '"';
    key = span('string key', key);
    return indent() + key + ': ' + html(val, indents);
  }).join(',\n');
  --indents;

  if (len) buf += '\n' + indent();
  buf += '}';

  return buf;
}
function html(obj, indents) {
  indents = indents || 1;

  function indent() {
    return Array(indents).join('  ');
  }

  if ('string' == typeof obj) {
    var str = escape(obj);
    if (urlRegex().test(obj)) {
      str = '<a href="' + str + '">' + str + '</a>';
    }
    return span('string value', '"' + str + '"');
  }

  if ('number' == typeof obj) {
    return span('number', obj);
  }

  if ('boolean' == typeof obj) {
    return span('boolean', obj);
  }

  if (null === obj) {
    return span('null', 'null');
  }

  var buf;

  if (Array.isArray(obj)) {
    ++indents;

    buf = '[\n' + obj.map(function(val){
      return indent() + html(val, indents);
    }).join(',\n');

    --indents;
    buf += '\n' + indent() + ']';
    return buf;
  }

  buf = '{';
  var keys = Object.keys(obj);
  var len = keys.length;
  if (len) buf += '\n';

  ++indents;
  buf += keys.map(function(key){
    var val = obj[key];
    key = '"' + key + '"';
    key = span('string key', key);
    return indent() + key + ': ' + html(val, indents);
  }).join(',\n');
  --indents;

  if (len) buf += '\n' + indent();
  buf += '}';

  return buf;
}
function html ( obj , indents ) { indents = indents || 1 ; function indent ( ) { return Array ( indents ) . join ( '  ' ) ; } if ( 'string' == typeof obj ) { var str = escape ( obj ) ; if ( urlRegex ( ) . test ( obj ) ) { str = '<a href="' + str + '">' + str + '</a>' ; } return span ( 'string value' , '"' + str + '"' ) ; } if ( 'number' == typeof obj ) { return span ( 'number' , obj ) ; } if ( 'boolean' == typeof obj ) { return span ( 'boolean' , obj ) ; } if ( null === obj ) { return span ( 'null' , 'null' ) ; } var buf ; if ( Array . isArray ( obj ) ) { ++ indents ; buf = '[\n' + obj . map ( function ( val ) { return indent ( ) + html ( val , indents ) ; } ) . join ( ',\n' ) ; -- indents ; buf += '\n' + indent ( ) + ']' ; return buf ; } buf = '{' ; var keys = Object . keys ( obj ) ; var len = keys . length ; if ( len ) buf += '\n' ; ++ indents ; buf += keys . map ( function ( key ) { var val = obj [ key ] ; key = '"' + key + '"' ; key = span ( 'string key' , key ) ; return indent ( ) + key + ': ' + html ( val , indents ) ; } ) . join ( ',\n' ) ; -- indents ; if ( len ) buf += '\n' + indent ( ) ; buf += '}' ; return buf ; }
Convert JSON Object to html.

@param {Object} obj
@return {String}
@api public
Convert JSON Object to html .