ServiceNow Tools · LessonBy Neelima, ServiceNow Architect · Published · current release · utility
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?
Frequently asked questions
What does the term XML / JSON formatter refer to in ServiceNow?
When building REST integrations you constantly read raw payloads. Format and validate them, and log them from script.
Practise this on your own free instance.