We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f8f3e9 commit a08b2b5Copy full SHA for a08b2b5
Modern Development/Service Portal Widgets/JSON Beautifier/Client_side.js
@@ -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