code: function toJson(obj, pretty) {
    if (typeof obj === 'undefined') return undefined;
    if (!isNumber(pretty)) {
      pretty = pretty ? 2 : null;
    }
    return JSON.stringify(obj, toJsonReplacer, pretty);
  }
docs: @ngdoc function
  @name angular.toJson
  @module ng
  @kind function
  
  @description
  Serializes input into a JSON-formatted string. Properties with leading $$ characters will be
  stripped since angular uses this notation internally.
  
  @param {Object|Array|Date|string|number} obj Input to be serialized into JSON.
  @param {boolean|number=} pretty If set to true, the JSON output will contain newlines and whitespace.
  If set to an integer, the JSON output will contain that many spaces per indentation (the default is 2).
  @returns {string|undefined} JSON-ified string representing `obj`.