{ "id": "api/common/JsonPipe", "title": "JsonPipe", "contents": "\n\n
\n
\n
\n \n API > @angular/common\n
\n \n
\n \n
\n

JsonPipelink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

Converts a value into its JSON-format representation. Useful for debugging.

\n\n \n
\n \n \n \n
\n {{ value_expression | json }}\n\n

NgModulelink

\n\n\n\n\n \n

Input valuelink

\n \n \n \n \n \n \n \n \n \n
\n \n value\n any\n

A value of any type to convert into a JSON-format string.

\n\n
\n \n \n
\n\n\n \n\n \n\n\n \n
\n

Usage noteslink

\n

The following component uses a JSON pipe to convert an object\nto JSON format, and displays the string in both formats for comparison.

\n\n@Component({\n selector: 'json-pipe',\n template: `<div>\n <p>Without JSON pipe:</p>\n <pre>{{object}}</pre>\n <p>With JSON pipe:</p>\n <pre>{{object | json}}</pre>\n </div>`\n})\nexport class JsonPipeComponent {\n object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}};\n}\n\n\n\n
\n\n\n\n
\n
\n\n\n" }