在go中使用lua示例, 基于gopher-lua!
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

14 рядки
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()")