Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to use JSON in workflow script?

ayordanov
Kilo Contributor

Hello,

I have the following issue. I have a table with a field called "json_output". The user must filled it with valid json and then I want to process this data in a workflow script. So far, I've read about

var parser = new JSONParser();

var blades = parser.parse(current.json_output.toString());

But it seems it doesn't work in server-side scripts. When the script is executed it outputs the following message:

JSONParser undefined, maybe missing global qualifier

Can anybody tell me how to use JSON in workflow script?

Thanks,

Alexander

1 ACCEPTED SOLUTION

You can also use JSON method to decode your json_output. See below,



var json = new global.JSON();


var blades = new JSON().decode(current.json_output.toString());



gs.log('keyName1 - ' + blades.keyName1);



View solution in original post

5 REPLIES 5

You can also use JSON method to decode your json_output. See below,



var json = new global.JSON();


var blades = new JSON().decode(current.json_output.toString());



gs.log('keyName1 - ' + blades.keyName1);