I have a functionality and looking for some approach to achieve this.
I have two diff API with response as below.
let ar0 = { "properties":{"role": ["myservice1", "myservice2", "myservice"],
"perm":["abcd","defc","mnop"]
}
};
let ar11 = [{ "role": ["myservice1", "myservice2"]}
,{"perm":["abcd","defc"]}];
My functionality is to create check box for a key like “role” and keep the common values(from both the arrays) checked and values available in ar0 to be unchecked.(ar11 will always have keys available in ar0 and no extras)
I am trying to implement this as below:
Create a new array by using both the the json like below and iterate over. “checked” key is to keep the checkbox checked and unchecked.
let output = [ { "role": [ { "cname": "myservice1", "ischecked": true },
{ "cname": "myservice2", "ischecked": true }, { "cname": "myservice", "ischecked": false } ] },
{ "perm": [ { "cname": "abcd", "ischecked": true }, { "cname": "defg", "ischecked": true }, { "cname": "mnop", "ischecked": false } ] } ]
Looking for recommendation to implement above functionality
Nitin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.