Coder Social home page Coder Social logo

lua-pretty-json's Introduction

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

License

MIT License

Copyright (c) 2018 xiedacon

lua-pretty-json's People

Contributors

ryanplusplus avatar xiedacon avatar chuckweiss avatar griffinmaxwell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.