1.1.1 • Published 5 years ago

json_to_lua v1.1.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

json_to_lua

convert json string to lua table

Using npm

>$ npm i json_to_lua

Note: add --save if you are using npm < 5.0.0

Sample

var jsonToLua = require("json_to_lua")

var jsObj = {a:"123", b:345, c:[1, 2, 3]};

// convert js object to lua string
var luaObj = jsonToLua.jsObjectToLua(jsObj);
console.log(luaObj);
//# result : {a="123",b=345,c={1,2,3}}

// convert json string to lua string
var luaObj1 = jsonToLua.jsonToLua(JSON.stringify(jsObj));
console.log(luaObj1);
//# result : {a="123",b=345,c={1,2,3}}

// convert js object to lua pretty
var luaObjPretty = jsonToLua.jsObjectToLuaPretty(jsObj, 1/*pretty mode depth*/);
console.log(luaObjPretty);
//# result :
//{
//	a = "123",
//	b = 345,
//	c = {1,2,3}
//}

// convert json string to lua pretty
var luaObjPretty = jsonToLua.jsonToLuaPretty(JSON.stringify(jsObj), 1/*pretty mode depth*/);
console.log(luaObjPretty);
//# result :
//{
//	a = "123",
//	b = 345,
//	c = {1,2,3}
//}

// convert string to lua table key style
var luaKey1 = jsonToLua.makeLuaKey(10001);
var luaKey2 = jsonToLua.makeLuaKey(1ABC);
var luaKey3 = jsonToLua.makeLuaKey(ABC);
//# result :
//{
//	luaKey1 = [10001]
//	luaKey2 = ["1ABC"]
//	luaKey3 = ABC
//}
1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.7

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago