📅  最后修改于: 2022-03-11 15:03:11.943000             🧑  作者: Mango
const sample = [{"id":"10","name":"Dave","urlName":"foo-bar","order":"-100","classId":"12","className":"David","classUrlName":"david-foo-bar"}];
const result = sample.reduce((acc, item) => {
return acc.set(item.name, {
id: item.id,
urlName: item.urlName,
})
}, new Immutable.Map())
console.log("Dave's Id", result.getIn(["Dave", "id"]));
console.log("Date's urlName", result.getIn(["Dave", "urlName"]));