Skip to content

Commit a08b2b5

Browse files
authored
Create Client_side.js
1 parent 2f8f3e9 commit a08b2b5

File tree

1 file changed

+18
-0
lines changed
  • Modern Development/Service Portal Widgets/JSON Beautifier

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
api.controller=function($scope) {
2+
/* widget controller */
3+
$scope.rawJson = '';
4+
$scope.formattedJson = '';
5+
$scope.error = '';
6+
7+
$scope.beautifyJSON = function(){
8+
try{
9+
$scope.error = '';
10+
const parsed = JSON.parse($scope.rawJson);
11+
$scope.formattedJson = JSON.stringify(parsed,null,2);
12+
}catch(e){
13+
$scope.error = 'Invalid JSON' + e.message;
14+
$scope.formattedJson = '';
15+
}
16+
};
17+
18+
};

0 commit comments

Comments
 (0)