我怎样才能将以下对象合并为一个:

对象一

{"risks": [
    {
        "forests_wildlife": ["The landscape"],
        "other": ["Something here"]
    } 
]}

对象二

{"riskDetails": [
    {
        "forests_wildlife": "The landscape",
        "affected_people": "1000-10,000",
        "affected_wildlife": "2-5 wildlife populations"
    },
    {
        "other": "Custom",
        "affected_people": "100-1000",
        "affected_wildlife": "5-10 wildlife populations"
    } 
]}

期望的输出

{"risks": [
    {
        "forests_wildlife": [
            {
                "The landscape" : {
                    "riskDetails": {
                        "affected_people": "1000-10,000",
                        "affected_wildlife": "2-5 wildlife populations"
                    }
                }
            }
        ],
        "other": [
            {
                "Custom something" : {
                    "riskDetails": {
                        "affected_people": "100-1000",
                        "affected_wildlife": "5-10 wildlife populations"
                    }
                }
            }
        ]
    },...
]}

我真的很感激任何帮助 . 只要解决方案有效,Lodash或没有lodash就可以了 .

编辑:

我认为,为了我的目的,我不必将两者合并为一个对象,但可以只通过第一个中的每个项目并在第二个中找到匹配 . 这是我提出的对我有用的片段:

const riskCategory = data.risks;
        const riskDetails = data.riskDetails;
        return _.map(riskCategory, category => {
            return _.map(category, (risk, key) => {
                return _.map(risk, (item, index) => {
                    var details = _.find(riskDetails, _.matchesProperty( key, item ));
                    if ( details ) {
                        return (
                            <tr key={index}>
                                <td> {item} </td>
                                <td> {details.affected_people} </td>
                                <td> {details.affected_wildlife} </td>
                            </tr>
                        );
                    }
                    return;
                });
            });
        });

它是一个嵌套的 Map ,在中间的某处找到并匹配,以便能够到达第二个对象的最内部 . 也许有另一种方法可以做到更清洁,更优雅 . 我是javascript的新手,我发现lodash帮助我让生活变得更轻松,但我不想太依赖它 .