Taíne Freitas
Taíne Freitas

Reputation: 143

How to exhibit a json with internal vectors?

So, I have to split a json, but I don't know how. I need that the name of a category goes shows in a tab. Here's a example of my json:

 "tabs": [
           {
            "General": [
                {
                    "created_at": "2019-11-29 11:32:11",
                    "name":'Test 1'
                },
                {
                    "created_at": "2019-11-29 11:32:11",
                    "name":'Test 2'
                },

            ]
           },
           {
            "One More": [
                {
                    "created_at": "2019-11-29 15:01:55",
                    "name": "Test 3"
                }
            ]
        }
    ]

The tab code I understand (is like this: https://react-bootstrap.github.io/components/tabs/), my problem is just show "General" or "One More" on the tab name, and the name changes... I know is a silly question, but I can't find a good explanation.

Thanks for the help!

Upvotes: 2

Views: 42

Answers (1)

Dupocas
Dupocas

Reputation: 21357

Following the docs to render one tab for each key of tabs

<Tabs defaultActiveKey="profile" id="uncontrolled-tab-example">
    {
        Object.keys(tabs).map(key =>(
            <Tab title={key} key={key}>
                Foo
             </Tab>
        ))
    }
</Tabs>

Object.keys(myObject) will provide you an array of strings representing each property of the original object

Upvotes: 1

Related Questions