I have the following JSON data:
{
"scan_stats": {
"med_compl_clin": [
{
"clin": "Miller RPH, Susan S",
"pct": "98"
},
{
"clin": "Rollins RN, Beth L",
"pct": "67"
},
{
"clin": "Jenkins, Coney RUTH",
"pct": "85"
},
{
"clin": "Moore RPH, Kenneth W",
"pct": "33"
},
{
"clin": "Isaacs RPH, Daniel",
"pct": "100"
}
],
"pt_compl_clin": [
{
"clin": "Miller RPH, Susan S",
"pct": "34"
},
{
"clin": "Rollins RN, Beth L",
"pct": "88"
},
{
"clin": "Wright , James ANTHONY",
"pct": "90"
},
{
"clin": "Jenkins, Coney RUTH",
"pct": "75"
},
{
"clin": "Moore RPH, Kenneth W",
"pct": "58"
}
]
}
}
I'm trying to figure out how I can change the above object into an array that has the all the pct (percentages) for each clin (clinician) once in an array. I want the clinicians that are not in both the med_compl_clin and the pt_compl_clin objects to have null in the array position for the object that particular clinician doesn't appear in:
[
["Miller RPH, Susan S", 98, 34],
["Rollins RN, Beth L", 67, 88],
["Wright , James ANTHONY", null, 90]
] ... to the end of all clinicians
I am trying to use underscore.js to do it but can't get it right.
mapover the first array andfindthe respectivepctvalue by comparing theclinvalues.