I have a code snippet like the following:
var items = ["element_1", "element_2", "element_3"];
for (int i = 0; i < item.length; i++) {
delete userFormJsonObject[i];
}
The userFormJsonObject is a Json object and I wish to delete the node from "element_1" to "element_3" which was defined in items array.
Here is what my JSON object looks like in Chrome debugger:
My problem is: the loop will automatically remove the double quote and I wish to preserve the double quote for my loop. I have tried to add \ escape character into my array, such as "\"element_1\"". But when I passed this into the loop, it seems not working.
I wish my loop runs just like:
delete $scope.userProfileDataFormTrimmed["account_id"];
delete $scope.userProfileDataFormTrimmed["active_directory_flag"];
...
Is there a good way to solve this problem?

userFormJsonObjectand what you'd like it to look like after the process?iwill have the values0,1, and then2. Did you meandelete userFormJsonObject[items[i]]? Regarding your updated question, the object shown doesn't have properties calledelement_1, etc. Regarding preserving the quotes, the object you've shown does not have quotes in its property names.