Config-UCL
view release on metacpan or search on metacpan
libucl-0.8.1/doc/lua_api.md view on Meta::CPAN
## Module `ucl`
This lua module allows to parse objects from strings and to store data into
ucl objects. It uses `libucl` C library to parse and manipulate with ucl objects.
Example:
~~~lua
local ucl = require("ucl")
local parser = ucl.parser()
local res,err = parser:parse_string('{key=value}')
if not res then
print('parser error: ' .. err)
else
local obj = parser:get_object()
local got = ucl.to_format(obj, 'json')
end
local table = {
str = 'value',
num = 100500,
null = ucl.null,
func = function ()
return 'huh'
end
}
print(ucl.to_format(table, 'ucl'))
-- Output:
--[[
num = 100500;
str = "value";
null = null;
func = "huh";
--]]
~~~
###Brief content:
**Functions**:
> [`ucl_object_push_lua(L, obj, allow_array)`](#function-ucl_object_push_lual-obj-allow_array)
> [`ucl.to_format(var, format)`](#function-uclto_formatvar-format)
**Methods**:
> [`parser:parse_file(name)`](#method-parserparse_filename)
> [`parser:parse_string(input)`](#method-parserparse_stringinput)
> [`parser:get_object()`](#method-parserget_object)
## Functions
The module `ucl` defines the following functions.
### Function `ucl_object_push_lua(L, obj, allow_array)`
This is a `C` function to push `UCL` object as lua variable. This function
converts `obj` to lua representation using the following conversions:
- *scalar* values are directly presented by lua objects
( run in 1.926 second using v1.01-cache-2.11-cpan-e1769b4cff6 )