diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-16 17:58:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-16 17:58:45 +0800 |
commit | 01af236ec7a9a0cf7e0075fe9cfa2280380c0ed2 (patch) | |
tree | 4c8fffc2b9fa593bb8001b29cab30448c1bda259 /src | |
parent | 4442a7ca616464d1fe2550b0c5794217c319cff3 (diff) | |
download | lua-language-server-01af236ec7a9a0cf7e0075fe9cfa2280380c0ed2.zip |
修正生成json的BUG
Diffstat (limited to 'src')
-rw-r--r-- | src/json/encode.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/json/encode.lua b/src/json/encode.lua index 135a51a1..4bba26de 100644 --- a/src/json/encode.lua +++ b/src/json/encode.lua @@ -1,8 +1,10 @@ + local rep = string.rep local format = string.format local gsub = string.gsub local sub = string.sub local sort = table.sort +local find = string.find local tostring = tostring local getmetatable = debug.getmetatable local type = type @@ -84,6 +86,11 @@ local function encode(data, key) index=index+1;lines[index] = tabs[n] .. ']' end elseif tp == 'number' then + data = tostring(data) + -- 判断 inf -inf -nan(ind) 1.#INF -1.#INF -1.#IND + if find(data, '%a') then + data = '0' + end if key then index=index+1;lines[index] = tabs[n] .. '"' .. gsub(key, '[\\\r\n\t"]', esc_map) .. '" : ' .. data else |