So I want to convert:
From:
{
  emailNotify: {
    EQ: true
  },
  foo: {
    bar: false
  }
}
To:
[
  {'condition': 'EQ', 'attribute': emailNotify, 'value': true},
  {'condition': 'bar', 'attribute': foo, 'value': false}
]
I tried the following code:
var fromObj={
   emailNotify: {
        EQ: true
    },
    foo: {
        bar: false
    }
};
console.log(Object.keys(fromObj));
var result = (Object.keys(fromObj)).reduce(function(p,c,i,a){
    var newObj={};
    newObj["condition"]=Object.keys(fromObj[c])[0];
    newObj["attribute"]=c;
    newObj["value"]=fromObj[c][Object.keys(fromObj[c])[0]];
    p.push(newObj);
    return p;
},[]);
console.log("result", result);
Is this the way you to would do it as well? I believe I'm not using reduce correctly?
PS: I get the right result! Just wanted to know if it is the elengant way or not?

fromObj[c][Object.keys(fromObj[c])[0]]though!Object.keys(fromObj[c])[0]instead of calling that multiple times. Just add anothervar.