ShouxTech / json-to-lua

Convert a JSON string to a Lua table

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json-to-lua

Convert a JSON string to a Lua table.

Code example Output example

How it works

First, it generates an abstract syntax tree from the JSON string.

Second, it uses recursive functions to go through all the elements in the tree. It then formats the element object to how it would appear in a Lua table, and then adds it to an array with all other formatted elements.

Third, it joins all the formatted elements together with commas and wraps it in curly braces.

About

Convert a JSON string to a Lua table


Languages

Language:JavaScript 100.0%