Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

Parse JSON response

This small code sample shows how to parse a JSON response. This is normally used in the Reply Handler of an HTTP request, in order to read the JSON response and capture a specific value such as a token.

The code fires the blur event. Another common event that may need to be fired, depending on how the site was coded, is the change event.

// put the JSON response in to a variable called 'json'
var json = response.content;
alert (json);
// use the Javascript parse() function to put the matching pairs in to the variable 'obj'
var obj = JSON.parse(json);
// We can now reference any JSON value by using obj.ValueName
token = obj.userToken;
alert ("TOKEN : " + token);