diff options
author | Silvan Mosberger <contact@infinisil.com> | 2024-06-13 03:13:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 03:13:11 +0200 |
commit | a1bae893c4750783f2a34f88a62aa32f7d21ef1b (patch) | |
tree | 0f59a08e2fc7e151a9d67102e4e19d740b36c265 /lib | |
parent | 15ef0de6ed9d1712403d9145a3060c2f9bb468e2 (diff) | |
parent | cfc6c9b6e433009a3f5c0a4c9cab526e09bd760a (diff) |
Merge pull request #318102 from TheCodedProf/private/thecodedprof/documentation-examples
lib.trivial: add examples for importJSON and importTOML
Diffstat (limited to 'lib')
-rw-r--r-- | lib/trivial.nix | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix index dee7eca9699a0..3284e3dbe4838 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -623,6 +623,37 @@ in { /** Reads a JSON file. + # Examples + :::{.example} + ## `lib.trivial.importJSON` usage example + + example.json + ```json + { + "title": "Example JSON", + "hello": { + "world": "foo", + "bar": { + "foobar": true + } + } + } + ``` + + ```nix + importJSON ./example.json + => { + title = "Example JSON"; + hello = { + world = "foo"; + bar = { + foobar = true; + }; + }; + } + ``` + + ::: # Inputs @@ -642,6 +673,35 @@ in { /** Reads a TOML file. + # Examples + :::{.example} + ## `lib.trivial.importTOML` usage example + + example.toml + ```toml + title = "TOML Example" + + [hello] + world = "foo" + + [hello.bar] + foobar = true + ``` + + ```nix + importTOML ./example.toml + => { + title = "TOML Example"; + hello = { + world = "foo"; + bar = { + foobar = true; + }; + }; + } + ``` + + ::: # Inputs |