Wednesday, 12 April 2017

Mental JSON cartwheels, match values by key

I have this JSON object:

{
    "_id" : ObjectId("58eedc4698d1712b870c8e40"),
    "valueObj" : {
        "58eedc4298d1712b870c8e0a" : false,
        "58eedc4298d1712b870c8e06" : true,
        "58eedc4198d1712b870c8e05" : true
    },
    "valueObjValues" : {
        "58eedc4298d1712b870c8e0a" : "git",
        "58eedc4298d1712b870c8e06" : "svn",
        "58eedc4198d1712b870c8e05" : "hg"
    },
}

I want to get an object that looks like:

{
git: false,
svn: true,
hg: true
}

every algorithm I have come up with is very verbose, anybody think of something quick and clever?



via Alexander Mills

No comments:

Post a Comment