IT CanvassTalk to an advisor
ServiceNow Tools · LessonBy , 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.
Set up your free instance →
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support