IT CanvassTalk to an advisor
ServiceNow Tools · LessonReviewed by Neelima, ServiceNow Architect · Updated · Published · current release · utility

ServiceNow XML / JSON formatter

Pretty-print payloads while building integrations.

Quick answer

REST integration work means reading raw payloads constantly, so format and validate them here and log them from script: JSON.stringify(obj, null, 2) inside gs.info() pretty-prints an object to the system log, and JSON.parse(request.body.dataString) turns an inbound body into an object you can read fields from in a Scripted REST API.

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.

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