File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
src/resources/pandoc/datadir Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 24
24
25
25
local json = { _version = " 0.1.2" }
26
26
27
+ -- taken from https://www.lua.org/pil/19.3.html
28
+ function pairsByKeys (t , f )
29
+ local a = {}
30
+ for n in pairs (t ) do table.insert (a , n ) end
31
+ table.sort (a , f )
32
+ local i = 0 -- iterator variable
33
+ local iter = function () -- iterator function
34
+ i = i + 1
35
+ if a [i ] == nil then return nil
36
+ else return a [i ], t [a [i ]]
37
+ end
38
+ end
39
+ return iter
40
+ end
41
+
27
42
---- ---------------------------------------------------------------------------
28
43
-- Encode
29
44
---- ---------------------------------------------------------------------------
@@ -86,7 +101,7 @@ local function encode_table(val, stack)
86
101
87
102
else
88
103
-- Treat as an object
89
- for k , v in pairs (val ) do
104
+ for k , v in pairsByKeys (val ) do
90
105
if type (k ) ~= " string" then
91
106
error (" invalid table: mixed or invalid key types" )
92
107
end
@@ -385,4 +400,4 @@ function json.decode(str)
385
400
end
386
401
387
402
388
- return json
403
+ return json
You can’t perform that action at this time.
0 commit comments