Javascript, Transforming object with underscore (or not)

后端 未结 2 569
野的像风
野的像风 2021-01-22 15:19

I am looking to prepare an object for send. It initially looks like so :

var myObj = {\"state\":{\"Saved\":true,\"Committed\":false,\"Published\":false},\"discip         


        
2条回答
  •  攒了一身酷
    2021-01-22 16:01

    You were nearly there with your answer. Use _.mapObject to retain the keys instead of map.

        var result = _.mapObject(myObj, function(value){
            return _.keys(_.pick(value, Boolean));
        });
    

提交回复
热议问题