ServiceNow Tools · LessonBy Neelima, ServiceNow Architect · Published · Updated · current release · utility
ServiceNow XML / JSON formatter
Pretty-print payloads while building integrations.
Quick answer
When building REST integrations you constantly read raw payloads. Format and validate them, and log them from script.
Key takeaways
- Pretty-print JSON in script
- Parse an inbound body
When building REST integrations you constantly read raw payloads. Format and validate them, and log them from script.
Pretty-print JSON in script
var obj = { number:'INC0010023', priority:1 };
gs.info(JSON.stringify(obj, null, 2));Parse an inbound body
var data = JSON.parse(request.body.dataString); gs.info(data.short_description);
Try it YourselfJavaScript
▸ Press Run to execute.
Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.
Quick check
+0 XPStreak ×0
Question 1 of 2
Which pretty-prints an object with indentation?
Practise this on your own free instance.