在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

пре 4 година
  1. local json = require("json")
  2. local jsonStringWithNull = [[{"a":{"b":1, "c":null}}]]
  3. local jsonString = [[{"a":{"b":1}}]]
  4. local result, err = json.decode(jsonStringWithNull)
  5. if err then error(err) end
  6. if not(result["a"]["b"] == 1) then error("must be decode") end
  7. print("done: json.decode()")
  8. local result, err = json.encode(result)
  9. if err then error(err) end
  10. if not(result==jsonString) then error("must be encode "..result) end
  11. print("done: json.encode()")