function toJson(obj, pretty) {
  return JSON.stringify(obj, toJsonReplacer, pretty ? '  ' : null);
}
@ngdoc function
@name angular.toJson
@function

@description
Serializes input into a JSON-formatted string.

@param {Object|Array|Date|string|number} obj Input to be serialized into JSON.
@param {boolean=} pretty If set to true, the JSON output will contain newlines and whitespace.
@returns {string} Jsonified string representing `obj`.