How can I read a JSON file that exists in the filesystem with Nix? Is this natively supported?
How can I read a JSON file that exists in the filesystem with Nix? Is this natively supported?
If we have a file example.json like:
{
"rev": "fcc9a7714053acb1aaf6913b99b6f49e0d13b1b7"
}
We can use the following where fromJSON will return an attribute set:
nix-repl> v = builtins.fromJSON (builtins.readFile "/path/to/example.json")
nix-repl> v.rev
"fcc9a7714053acb1aaf6913b99b6f49e0d13b1b7"