JSON Formatter is an AngularJS directive for rendering JSON objects in HTML with a collapsible navigation.
Install via Bower
bower install json-formatter --save
Add jsonFormatter
to your app dependencies
angular.module('myApp', ['jsonFormatter'])
Use <json-formatter>
directive
<json-formatter open="1" json="{my: 'json'}"></json-formatter>
open
attribute accepts a number that indicated how many levels JSON should be open
You can set following configurations via JSONFormatterConfig
provider.
Changing these configurations will impact all demos
ng-repeat
If you are iterating in an array of objects, make sure you are using track by $index
to avoid adding extra $$hashKey
to your objects.
track by $index
track by $index
To use dark theme add json-formatter-dark
class this directive. Note that json-formatter-dark
class make text and other elements lighter so they look good on a dark background.
(for performance testing)