From cfc6c9b6e433009a3f5c0a4c9cab526e09bd760a Mon Sep 17 00:00:00 2001 From: Samuel Shuert Date: Fri, 7 Jun 2024 17:22:17 -0400 Subject: lib.trivial.importJSON: add example Add parity with importTOML. --- lib/trivial.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'lib') diff --git a/lib/trivial.nix b/lib/trivial.nix index f4a8f0d9bec57..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 -- cgit 1.4.1