angular-json-pretty
A directive make json object or string printed in human readable way
Install
bower install --save angular-json-pretty
Import
<link rel="stylesheet" href="angular-json-pretty.css"/>
<script type="text/javascript" src="angular-json-pretty.js"></script>
angular-json-pretty
also supportAMD
andCMD
. So you may already know how to import it into your code in the way you like.
Usage
Print JSON Object
<pre json-pretty data="jsonObj"></pre>
demo.controller('DemoController', function($scope) {
$scope.jsonObj = {
labels: ['1', '2', '3', '4', '5', '6'],
series: [{
name: 'Fibonacci sequence',
data: [1, 2, 3, 5, 8, 13]
}, {
name: 'Golden section',
data: [1, 1.618, 2.618, 4.236, 6.854, 11.09]
}]
};
});
Print JSON String
<pre json-pretty data="jsonStr"></pre>
demo.controller('DemoController', function($scope) {
$scope.jsonStr = '{"name":"Test","series":[{"name":"Fibonacci sequence","data":[1,2,3,5,8,13]}]}';
});