简体   繁体   English

尝试从数组中的子对象创建数组

[英]Trying to create array from child objects in array

I have an array that has a top level I need to get rid of, I am using Angular7 and I am not sure how to go about pulling out the child objects from this array. 我有一个需要删除的顶级数组,我正在使用Angular7,但不确定如何从该数组中拉出子对象。 I would like to get rid of the "toplevel" level so you just have the objects with properties. 我想摆脱“顶层”级别,这样您就可以拥有带有属性的对象。 Any help would be appreciated. 任何帮助,将不胜感激。

{
    "toplevel": [
        {
            "SetName": "name1",
            "description": "blah blah blah",
            "managingEntitySource": "blah blah blah",
            "effectiveDate": "01/01/9999",
            "terminationDate": "01/01/9999",
            "systemEffectiveDate": "01/01/9999",
            "systemTerminationDate": "01/01/9999",
            "comments": "blah blah blah",
            "lastProcessDate": "01/01/9999"
        },
        {
            "SetName": "name2",
            "description": "blah blah blah",
            "managingEntitySource": "blah blah blah",
            "effectiveDate": "01/01/9999",
            "terminationDate": "01/01/9999",
            "systemEffectiveDate": "01/01/9999",
            "systemTerminationDate": "01/01/9999",
            "comments": "blah blah blah",
            "lastProcessDate": "01/01/9999"
        }
    ]
}

Here is what I am looking for after: 这是我要寻找的:

[
        {
            "SetName": "name1",
            "description": "blah blah blah",
            "managingEntitySource": "blah blah blah",
            "effectiveDate": "01/01/9999",
            "terminationDate": "01/01/9999",
            "systemEffectiveDate": "01/01/9999",
            "systemTerminationDate": "01/01/9999",
            "comments": "blah blah blah",
            "lastProcessDate": "01/01/9999"
        },
        {
            "SetName": "name2",
            "description": "blah blah blah",
            "managingEntitySource": "blah blah blah",
            "effectiveDate": "01/01/9999",
            "terminationDate": "01/01/9999",
            "systemEffectiveDate": "01/01/9999",
            "systemTerminationDate": "01/01/9999",
            "comments": "blah blah blah",
            "lastProcessDate": "01/01/9999"
        }
    ]

 var jsonObject = { "toplevel": [ { "SetName": "name1", "description": "blah blah blah", "managingEntitySource": "blah blah blah", "effectiveDate": "01/01/9999", "terminationDate": "01/01/9999", "systemEffectiveDate": "01/01/9999", "systemTerminationDate": "01/01/9999", "comments": "blah blah blah", "lastProcessDate": "01/01/9999" }, { "SetName": "name2", "description": "blah blah blah", "managingEntitySource": "blah blah blah", "effectiveDate": "01/01/9999", "terminationDate": "01/01/9999", "systemEffectiveDate": "01/01/9999", "systemTerminationDate": "01/01/9999", "comments": "blah blah blah", "lastProcessDate": "01/01/9999" } ] }; var innerArray = jsonObject.toplevel; console.log(innerArray); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM