简体   繁体   中英

Get JSON object value using JS code in Zapier

Can somebody tell me how to get the productName out of the "step 1" output to the right, using JS code. I believe that the output from step 1 is an JSON object.

Or are there any easier ways doing this?

Thanks in advance!

Something like this may work for you. Although dealing with the lines containing objects may require more.

var lines = inputData.productName.split("\n");
var obj = {};

for (var i = 0; i < lines.length; i++) {
  var pair = lines[i].split(":");
  obj[pair[0]] = pair[1];
}
return obj;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM