Loading JSON data

I making a plugin-based system where plugin authors can provide plugin data in the form of JSON files. Justin helped me find the following solution:

npm install --save-dev system-json

then:

System.import('foo/data.txt!system-json')

The file format can be anything (including JS), and the data will be loaded as a string and parsed using JSON.parse, giving us a consumable Object.

Answer was discovered here on gitter.

1 Like

Thanks for submitting. I’m going to clean up a few formatting things.

And one additional note, in most apps, you shouldn’t be using System.import() to load the vast majority of modules in your application. Instead you can do:

import json from "foo/data.text!system-json"