Encode
cloud.encode
Collection of encoding tools.
local res = cloud.encode.< method >( < parameters > )
JSON
.json
Encode a Lua table into a JSON string. Performs the reverse of decode.json.
cloud.encode.json( tbl )
Example
local tbl = { name = "Jill" } local json_str = cloud.encode.json( tbl ) --Produces: {"name":"Jill"}
Query String
.qstr
Encode the Lua table to a query args string according to the URI encoded rules.
cloud.encode.qstr( args_tbl )
Parameters
Name | Description | Type | Default | Requried |
---|---|---|---|---|
args_tbl |
A table object with the argument keys | table |
nil |
Y |
local args = { name = 'Jim', page = 7, id = 2 } local args_str = cloud.encode.qstr( args ) --Produces: page=7&name=Jim&id=2
URI
.uri
Escape string as a URI component.
cloud.encode.uri( str )
Example
local esc = cloud.encode.uri( "Hello Lua" ) -- esc = "Hello%20Lua"
Base64
.b64
Encodes a string to a base64 digest.
cloud.encode.b64( raw_str )
Example
local res = cloud.encode.b64( "Hello Coronium!" ) --Produces: e*+x