I am rendering this data in a table, how can I convert Cuisine_style into array???
[
{
"Name": "Martine of Martine's Table",
"City": "Amsterdam",
"Cuisine_Style": "['French', 'Dutch', 'European']",
"Ranking": 1,
"Rating": 5,
"Number of Reviews": 136
},
{
"Name": "De Silveren Spiegel",
"City": "Amsterdam",
"Cuisine_Style": "['Dutch', 'European', 'Vegetarian Friendly', 'Gluten Free Options']",
"Ranking": 2,
"Rating": 4.5,
"Number of Reviews": 812
}
]
If you absolutely must consume the data in this format, you can replace the single quotes with double quotes to make them JSON-compliant:
const data = [
{
"Name": "Martine of Martine's Table",
"City": "Amsterdam",
"Cuisine_Style": "['French', 'Dutch', 'European']",
"Ranking": 1,
"Rating": 5,
"Number of Reviews": 136
},
{
"Name": "De Silveren Spiegel",
"City": "Amsterdam",
"Cuisine_Style": "['Dutch', 'European', 'Vegetarian Friendly', 'Gluten Free Options']",
"Ranking": 2,
"Rating": 4.5,
"Number of Reviews": 812
}
];
for (const item of data)
item['Cuisine_Style'] = JSON.parse(item['Cuisine_Style'].replace(/'/g, '"'));
console.log(data);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments