angular-json-print
Angular directive to pretty-print and syntax-highlight JSON.
Usage
- Include 'json-print' as a dependency for your app.
angular.module('myApp', ['json-print'])
- Add the directive
json-print
to an element, along with the data source
Note: The use of an element like <pre>
is required to preserve indentation and line breaks, but has no effect on highlighting.
Arguments
json-print
- Accepts either a regular JavaScript object, or a string of JSON.json-indent
- Optional - Level of indentation, defaults to four spaces.
Markup
Values, properties, braces and brackets are wrapped in <span>
s with the following classes:
-
Properties
"foo": -
Strings. Any HTML-markup is escaped and displayed as text.
"String with HTML" -
Numbers. Additional classes for zero, and positive and negative numbers.
01-1 -
Booleans. Additional classes for true/false.
truefalse -
Null
null -
Objects
{} -
Arrays
[]