diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 16:05:34 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-29 16:05:34 +0800 |
commit | 4b96bc247b4b345757e43bb54451b482d7bfd5bc (patch) | |
tree | 27de63ce6eece283bc80109893c149dd6647ed57 /server | |
parent | d2ee2b2d2821e1f2306bbe99c050b2d052c028ec (diff) | |
download | lua-language-server-4b96bc247b4b345757e43bb54451b482d7bfd5bc.zip |
为了保证一致,使用\r\n作为换行符
Diffstat (limited to 'server')
-rw-r--r-- | server/src/json/encode.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/server/src/json/encode.lua b/server/src/json/encode.lua index 93d0b954..97a1680b 100644 --- a/server/src/json/encode.lua +++ b/server/src/json/encode.lua @@ -34,16 +34,16 @@ local function encode(data, key) if not data[1] and next(data) then -- 认为这个是哈希表 if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": {\n' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": {\r\n' else - index=index+1;lines[index] = tabs[n] .. '{\n' + index=index+1;lines[index] = tabs[n] .. '{\r\n' end local meta = getmetatable(data) local sep if meta and meta.__pairs then for k, v in meta.__pairs(data), data do if encode(v, k) then - index=index+1;lines[index] = ',\n' + index=index+1;lines[index] = ',\r\n' sep = true end end @@ -57,31 +57,31 @@ local function encode(data, key) for j = 1, i do local k = list[j] if encode(data[k], k) then - index=index+1;lines[index] = ',\n' + index=index+1;lines[index] = ',\r\n' sep = true end end end if sep then - lines[index] = '\n' + lines[index] = '\r\n' end index=index+1;lines[index] = tabs[n] .. '}' else -- 认为这个是数组 if key then - index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": [\n' + index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '": [\r\n' else - index=index+1;lines[index] = tabs[n] .. '[\n' + index=index+1;lines[index] = tabs[n] .. '[\r\n' end local sep for k, v in pairs(data) do if encode(v) then - index=index+1;lines[index] = ',\n' + index=index+1;lines[index] = ',\r\n' sep = true end end if sep then - lines[index] = '\n' + lines[index] = '\r\n' end index=index+1;lines[index] = tabs[n] .. ']' end |