Search code examples
javascriptjavascript-objects

How to Map JSON in React?


I have JSON format , but how to map the given JSON in Recat. Can anybody suggest me the solution?For Simple JSON I know how to Map, but here how can I map?

Here is the JSON:

const JSON = [
  {
    column1: {
      display_name: "Status",
      content: "<>",
      isMandatory: true / false,
      order: 1,
      enable: true / false,
    },
    column2: {
      display_name: "Study",
      content: "<>",
      isMandatory: true / false,
      order: 2,
      enable: true / false,
    },
    column3: {
      display_name: "Status",
      content: "<>",
      isMandatory: true / false,
      order: 1,
      enable: true / false,
    },
  },
];

Solution

  • Please try to map the data like

    Object.keys(JSON[0]).map(item => {}).

    This will help

    In order to access the item inside, you can do as

    Object.keys(JSON[0]).map(item => JSON[0][item])