2021-08-15 19:06:48 +08:00
|
|
|
local M = {}
|
2022-01-03 16:30:05 +08:00
|
|
|
-- should use local val
|
|
|
|
local fn = nil
|
2021-08-15 19:06:48 +08:00
|
|
|
|
|
|
|
if vim.fn == nil then
|
|
|
|
fn = require('spacevim').fn
|
|
|
|
else
|
|
|
|
fn = vim.fn
|
|
|
|
end
|
|
|
|
|
|
|
|
-- M._vim = require('spacevim.api').import('vim')
|
|
|
|
-- M._iconv = require('spacevim.api').import('iconv')
|
|
|
|
|
|
|
|
function M._json_null()
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function M._json_true()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function M._json_false()
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if fn.exists('*json_decode') then
|
|
|
|
function M.json_decode(json)
|
|
|
|
if json == '' then
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
return fn.json_decode(json)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
end
|
|
|
|
|
|
|
|
if fn.exists('*json_encode') then
|
|
|
|
function M.json_encode(val)
|
|
|
|
return fn.json_encode(val)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|