I want to bundle JSON data with a hex package.
Consider this function:
def list_tlds() do
File.read!("data/tlds.json") |> Jason.decode!()
end
The file data/tlds.json
exists, and of course it works locally (relative to the directory I run mix
), but when this package is a hex dependency, data/tlds.json
can’t be found.
I’ve had several use-cases for bundling JSON data with a hex package:
- Domain registrar client library: bundling a list of TLDs supported by the registrar.
- OEmbed library: bundle a list of common providers.
By bundling this data in its JSON source format, it makes it easier to update. If the source data changes I can simply download the new version and update my package.
Is this possible?