How to separate json response

AnilM99
Tera Expert

Hi Team,

 

I got the result like below:

[{"title":"Students","link":"https:\/\/google.com\/wiki\/students\/"},{"title":"Control","link":"https:\/\/google.com\/wiki\/control\/"},{"title":"IQ- Engine","link":"https:\/\/google.com\/wiki\/iq-engine\/"}]

 

My requirement is how to load the flow designer outputs variables individually 

Like.,

title : Students Link : https:\/\/google.com\/wiki\/students\/

title : Control, Link : https:\/\/google.com\/wiki\/control\/

title : IQ- Engine, Link : https:\/\/google.com\/wiki\/iq-engine\/

 

Help me on the same

Thanks!

1 ACCEPTED SOLUTION

SunilKumar_P
Giga Sage

Hi @AnilM99, can you try below?

 

var response = '[{"title":"Students","link":"https://google.com/wiki/students/"},{"title":"Control","link":"https://google.com/wiki/control/"},{"title":"IQ-Engine","link":"https://google.com/wiki/iq-engine/"}]';

var parsedResponse = JSON.parse(response);

var firstObj = parsedResponse[0];
var secondObj = parsedResponse[1];
var thirdObj = parsedResponse[2];



Regards,
Sunil

View solution in original post

5 REPLIES 5

dgarad
Giga Sage

Hi @AnilM99 

try below code

var result = '[{"title":"Students","link":"https:\/\/google.com\/wiki\/students\/"},{"title":"Control","link":"https:\/\/google.com\/wiki\/control\/"},{"title":"IQ- Engine","link":"https:\/\/google.com\/wiki\/iq-engine\/"}]';
var resultObj = JSON.parse(result); 
for(var i = 0; i<resultObj.length; i++){
    gs.log("title: "+resultObj[i].title +" link : "+resultObj[i].link); 
}
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad