I'm currently utilizing a dexi.io robot for the purpose of automating data extraction from permit databases. This particular robot has the capability to process custom JavaScript in order to dissect the incoming JSON object.
While this code does function correctly at times, successfully parsing the incoming JSON, it unfortunately fails to operate effectively in nearly all scenarios. An error message stating "cannot read property of length undefined" frequently appears.
If you'd like to test out the API that is functioning properly, click on the following link:
Below is the JavaScript code being used:
var people = JSON.parse(json).value;
var arr = [];
function getCountry(member) {
try {
return member.fields.name;
} catch(err) {
return "";
}
}
for (i = 0; i < people.length; i++) {
var member = people[i];
var obj =
{
"name": member.name,
"Country": getCountry(member),
"alias": member.alias
};
arr.push(obj);
}
return arr;