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 2424
2525local json = { _version = " 0.1.2" }
2626
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+
2742---- ---------------------------------------------------------------------------
2843-- Encode
2944---- ---------------------------------------------------------------------------
@@ -86,7 +101,7 @@ local function encode_table(val, stack)
86101
87102 else
88103 -- Treat as an object
89- for k , v in pairs (val ) do
104+ for k , v in pairsByKeys (val ) do
90105 if type (k ) ~= " string" then
91106 error (" invalid table: mixed or invalid key types" )
92107 end
@@ -385,4 +400,4 @@ function json.decode(str)
385400end
386401
387402
388- return json
403+ return json
You can’t perform that action at this time.
0 commit comments