How to Parse JSON Data?

I was working with a client recently who was just starting their journey into the world of Web Services using REST. This is a very powerful technology which allows two systems to exchange data using HTTP [POST (Create), GET (Read), PUT (Update/Replace), PATCH (Update/Modify), DELETE (Delete)] with JSON (JavaScript Object Notation) to exchange data. To work with this JSON data, ServiceNow gives a few methods. The confusing part to most new admins is that there are separate methods depending on if the parsing is done on the Server side, or Client side. Here are the methods to use for both:

Client Side:

JSON.stringify(yourJSONObject) //Encode your object into a string
JSON.parse(yourJSONString) //Decode your JSON String into an Object

Server Side:

new global.JSON().encode(yourJSONObject); //Encode your object into a String
new global.JSON().decode(yourJSONString); //Decode your JSON String into an Object

One nice thing about using REST in ServiceNow is that they provide a number of APIs (Table API, Aggregate, Import Set, Performance Analytics) based upon what type of integration is needed.

An additional nice feature that came in the Fuji release was the “REST API Explorer” which allows you to easily test the different REST methods with different data.

A similar tool that can be used externally to test can be found at

Here are some more links to help you along your REST journey:

Leave a Reply

Your email address will not be published. Required fields are marked *