I have multiple json files, and want to transform they to one simple json file and use json-loader to require it, like this:
import dictionary from './distFile.json';
Example:
file1.json
{a:"b"}
file2.json
{b:"a"}
distFile.json should be:
{a:"b",b:"a"}
How can I do that?
Or there is anyway to do something like that:
import dictionary from ['./file1.json','./file2.json']; ??
Make a third file that you require both files in.
combined.js
import file1 from './file1.json';
import file2 from './file2.json';
export default { ...file1, ...file2 };
Then just import that file:
import combinedJson from './combined.js'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With