projects/aports·blob master · refs

27 lines · 921 B

1From: Jakub Jirutka <[email protected]>
2Date: Sun, 18 Dec 2022 19:43:00 +0100
3Subject: [PATCH] Add support for cjson
4
5--- a/src/cliargs/config_loader.lua
6+++ b/src/cliargs/config_loader.lua
7@@ -36,14 +36,16 @@
8
9 --- Load configuration from a JSON file.
10 ---
11- --- Requires the "dkjson"[1] module to be present on the system. Get it with:
12+ --- Requires the "cjson"[1] or "dkjson"[2] module to be present on the system. Get it with:
13 ---
14- --- luarocks install dkjson
15+ --- luarocks install cjson
16 ---
17- --- [1] http://dkolf.de/src/dkjson-lua.fsl/home
18+ --- [1] https://www.kyne.com.au/~mark/software/lua-cjson.php
19+ --- [2] http://dkolf.de/src/dkjson-lua.fsl/home
20 from_json = function(filepath)
21 local src, config, _, err
22- local json = require 'dkjson'
23+ local ok, json = pcall(require, 'cjson')
24+ if not ok then json = require 'dkjson' end
25
26 src, err = read_file(filepath)
27