Files
Angular-Docs-Cn/modules/@angular/common/src/pipes/json_pipe.ts
T

27 lines
641 B
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
2016-06-08 16:38:52 -07:00
import {Pipe, PipeTransform} from '@angular/core';
2016-05-31 15:22:59 -07:00
import {Json} from '../facade/lang';
2015-05-18 09:24:52 -07:00
2016-06-08 16:38:52 -07:00
2015-05-18 09:24:52 -07:00
/**
* Transforms any input value using `JSON.stringify`. Useful for debugging.
2015-05-18 09:24:52 -07:00
*
* ### Example
* {@example core/pipes/ts/json_pipe/json_pipe_example.ts region='JsonPipe'}
*
* @stable
2015-05-18 09:24:52 -07:00
*/
@Pipe({name: 'json', pure: false})
2015-08-12 12:04:54 -07:00
export class JsonPipe implements PipeTransform {
transform(value: any): string { return Json.stringify(value); }
2015-05-18 09:24:52 -07:00
}