What i am trying to achive is values are sent to via REST message, i am trying to place these values in a JSON format, so they can be placed into a field on a form.
var membersToAddArry = [];
membersToAddArry = request.queryParams.MembersToAdd.toString().split(";");
for(var x = 0; x < membersToAddArry.length-1; x++)
{
dn = membersToAddArry[x].toString();
userJSONAdd["DistinguishedName"] = dn;
userJSONAddn[x] = userJSONAdd;
}
return userJSONAddn;
Data sent:
CN=smcgh,OU=Lost-Found,OU=Corp,DC=test,DC=COMPANY,DC=com;
CN=syouz,OU=Lost-Found,OU=Corp,DC=test,DC=COMPANY,DC=com;
This returns:
{
"result": {
"0": {
"DistinguishedName": "CN=syouz,OU=Lost-Found,OU=Corp,DC=test,DC=COMPANY,DC=com"
},
"1": {
"DistinguishedName": "CN=syouz,OU=Lost-Found,OU=Corp,DC=test,DC=COMPANY,DC=com"
}
}
}
The two bits of information are repeating how can i stop this?
""
, and you're overwritinguserJSONAdd
in each loop, so only the last element remains, which happens to be an empty string…membersToAddArry
to remove duplicates elements