在go中使用lua示例, 基于gopher-lua!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

14 lines
460 B

local json = require("json")
local jsonStringWithNull = [[{"a":{"b":1, "c":null}}]]
local jsonString = [[{"a":{"b":1}}]]
local result, err = json.decode(jsonStringWithNull)
if err then error(err) end
if not(result["a"]["b"] == 1) then error("must be decode") end
print("done: json.decode()")
local result, err = json.encode(result)
if err then error(err) end
if not(result==jsonString) then error("must be encode "..result) end
print("done: json.encode()")