Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
api.controller=function($scope) {
/* widget controller */
$scope.rawJson = '';
$scope.formattedJson = '';
$scope.error = '';

$scope.beautifyJSON = function(){
try{
$scope.error = '';
const parsed = JSON.parse($scope.rawJson);
$scope.formattedJson = JSON.stringify(parsed,null,2);
}catch(e){
$scope.error = 'Invalid JSON' + e.message;
$scope.formattedJson = '';
}
};

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="container p-3">
<h3>JSON Beautifier</h3>
<div class="form-group mt-3">
<label>Paste JSON Here</label>
<textarea class="form-control" rows="8" ng-model="rawJson" placeholder='{"key":"value"}'></textarea>
</div>
<div class="mt-2">
<button class="btn btn-primary btn-sm mr-1" ng-click="beautifyJSON()">
Beautify
</button>
</div>
<div class="mt-3" ng-if="error">
<div class="alert alert-danger">
{{error}}
</div>
</div>
<div class="mt-3" ng-if="formattedJson">
<label>Formatted JSON:</label>
<pre class="bg-light p-3" style="overflow-x:auto">{{formattedJson}}</pre>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## JSON Beautifier Widget

The JSON Beautifier widget is a developer-focused tool designed to make working with JSON in ServiceNow fast, easy and efficient. It helps admins, developers and testers handles JSON payloads from APIs, Integration etc.

## Benefits
- Reduces time spent manually formatting or checking JSON.
- Helps identify error or differences between JSOn payload quickly

## Output
![A test image](demo.png)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading