i have a source code of data.js , i want to be able to import json file automatically without copy manually
export const me = {
"gender": "male",
"name": "Billy Koswara",
"location": {
"street": "Jl. Sindoro",
"city": "Medan",
"state": "Sumatera Utara",
"postcode": 20212
},
"email": "koswarabilly@gmail.com",
"login": {
"username": "koswarabilly",
"password": "frodo1",
"salt": "0cSpyp70",
"md5": "bf758d9c79ef3c8a2c3fd900fb0c3148",
"sha1": "4f28fcd2d5e5ae5e0ff55b7528841e350cabf9fb",
"sha256": "1d44ef3ad01dafe929c56021498d8a6d89b2c438bd3f6a07de777ed35b98b5e1"
},
"dob": "1999-11-15",
"registered": "2010-08-09 13:37:38",
"phone": "(589)-070-0928",
"cell": "(110)-065-6280",
"id": {
"name": "SSN",
"value": "408-64-0336"
},
"nat": "US"
};
Atul Sharma
Full Stack Developer | Cloud Native Applications
Its pretty straight
import DATA from './data.json';Now use your
DATA.genderIf dosen't work, try
export defaultinstead ofexport const.Also, save that json file as
.jsPS : Alternatively, you can use
json-loadermodule to manage json imports.