flatten, flattenDeep or flattenDepth of lodash accept only an array. How to smooth a nested object?
var data = {
"dates": {
"expiry_date": "30 sep 2018",
"available": "30 sep 2017",
"min_contract_period": [{
"id": 1,
"name": "1 month",
"value": false
}, {
"id": 2,
"name": "2 months",
"value": true
}, {
"id": 3,
"name": "3 months",
"value": false
}]
},
"price": {
"curreny": "RM",
"min": 1500,
"max": 2000
}
}
I want the attached property to be the first level, for example, expiry_date should be level 1, not in dates, and I think the dates should disappear, and this is no longer needed. I can do it manually, use map (), but I want to use lodash to facilitate the task.
source
share