Skip to content
Pretty json serializer and parser for lua.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/pretty
.gitignore
LICENSE
README.md
dist.ini

README.md

lua-pretty-json

MIT

Usage

local json = require "pretty.json"

local str = json.stringify({
    "aa\"\a\v", "ccc", true, false,
    {
        a = "a",
        b = "a",
        "aaa", "ccc", "ddd",
    }
}, nil, 4)

print(str)
-- [
--     "aa\"\u0007\u000b",
--     "ccc",
--     true,
--     false,
--     {
--         "1": "aaa",
--         "2": "ccc",
--         "3": "ddd",
--         "a": "a",
--         "b": "a"
--     }
-- ]


json.parse(str)

API

  • json.stringify(obj, replacer, space, print_address)
    • obj <any> 需要序列化的值
    • replacer <function>js JSON.stringify
    • space <number> 空格数
    • print_address <boolean> 输出内存地址
  • json.parse(str, without_null)
    • str <string> 需要反序列化的值
    • without_null <boolean> 是否输出 null 值,�默认使用 json.null
  • json.null

License

MIT License

Copyright (c) 2018 xiedacon

You can’t perform that action at this time.