My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to filter array of objects which contains another array of objects and extract out that objects ?

pourushsingh gaur's photo
pourushsingh gaur
·Oct 7, 2018

So here is my Array :

[
    {
      "a": "2",
      "ss": [
        {
          "name": "pourush",
          "age": "25"
        },
        {
          "name": "Mak",
          "age": "25"
        }
      ]
    },
     {
      "b": "3",
      "ss": [
        {
          "name": "James",
          "age": "19"
        },
        {
          "name": "shaun",
          "age": "20"
        }
      ]
    }
  ]

Now , This is an array of objects. I want to loop this array and want to go at "ss" and extract both of the objects.

The result I need is Array of objects which will contain this ss objects.

  {
          "name": "pourush",
          "age": "25"
        },
        {
          "name": "Mak",
          "age": "25"
        },
    {
          "name": "James",
          "age": "19"
        },
        {
          "name": "shaun",
          "age": "20"
        }

]