Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
2.7 KB
|
Line | |
---|
1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Pipe } from '@angular/core';
|
---|
9 | /**
|
---|
10 | * @ngModule CommonModule
|
---|
11 | * @description
|
---|
12 | *
|
---|
13 | * Converts a value into its JSON-format representation. Useful for debugging.
|
---|
14 | *
|
---|
15 | * @usageNotes
|
---|
16 | *
|
---|
17 | * The following component uses a JSON pipe to convert an object
|
---|
18 | * to JSON format, and displays the string in both formats for comparison.
|
---|
19 | *
|
---|
20 | * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
|
---|
21 | *
|
---|
22 | * @publicApi
|
---|
23 | */
|
---|
24 | export class JsonPipe {
|
---|
25 | /**
|
---|
26 | * @param value A value of any type to convert into a JSON-format string.
|
---|
27 | */
|
---|
28 | transform(value) {
|
---|
29 | return JSON.stringify(value, null, 2);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | JsonPipe.decorators = [
|
---|
33 | { type: Pipe, args: [{ name: 'json', pure: false },] }
|
---|
34 | ];
|
---|
35 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoianNvbl9waXBlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tbW9uL3NyYy9waXBlcy9qc29uX3BpcGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLElBQUksRUFBZ0IsTUFBTSxlQUFlLENBQUM7QUFFbEQ7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFFSCxNQU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