I've been programming in React for a couple days now and have come across an issue utilizing a JSON file.
I'm currently using a hard coded list of...
const vendorList = [
{
id: 0,
name: "Laerdal Medical Corporation",
sections: [
{
name: "Product",
payload: [
{id: 1, name: "ASL 5000 Lung Solution"},
]
},
{
name: "Demos",
payload: [
{id: 1, name: "ASL 5000 Lung Solution", url: "ASL 5000 Lung Solution - High Fidelity Lungs for SimMan and SimBaby (laerdal.com)", type: "video"}
]
To populate some "VendorCards". I now have a JSON file with the same data in it...
{
"vendorList" : [
{
"id": 1,
"name": "Laerdal Medical Corporation",
"sections": [
{
"name": "Products",
"payload": [
{"id": 1, "name": "ASL 5000 Lung Solution"}
]
},
{
"name": "Demos",
"payload": [
{"id": 1, "name": "ASL 5000 Lung Solution", "url": "ASL 5000 Lung Solution - High Fidelity Lungs for SimMan and SimBaby (laerdal.com)", "type": "video"}
]
}
],
"tags": ["Tag 1","Tag 2"]
}]
How do I go about changing from my hardcoded list, to my JSON object? I am able to import the JSON object after reading other stackoverflow questions using import myJson from './data.json'
, but can't figure out how to put the json object in vendorlist
. Thanks for your time!