JSON files are automatically parsed into an object – they cannot be used as assets for this reason. If you really want to use as plain text then you could change the extension to .txt
. Otherwise if you do const obj = require('blah.json')
then obj
will already contain the keys of the JSON file like obj.foo
and obj.bar
if blah.json
’s contents are { foo: ..., bar: ..., ... }
.
1 Like