Skip to content

Convert Lua tables to and from JSON

Notifications You must be signed in to change notification settings

kcwiki/lua-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-json

Version

Convert Lua tables to and from JSON.

Install

yarn add lua-json

Usage

const { format, parse } = require('lua-json')

format({ x: 1 }) // 'return { x = 1 }'
parse('return { x = 1 }') // { x: 1 }

API

type Json = null | boolean | number | string | Json[] | { [_: string]: Json }

format(
  value: Json,
  options?: {
    eol: string = '\n',
    singleQuote: boolean = true,
    spaces: null | number | string = 2,
  }
): string

parse(value: string): Json

TODO

  • More formatting options à la prettier: printWidth (!), trailingComma, bracketSpacing.

About

Convert Lua tables to and from JSON

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published