Skip to main content

Encode application/x-www-form-urlencoded (http.table_to_form_urlencoded)

Declaration

encoded = http.table_to_form_urlencoded(tbl)

Parameters

  • tbl
    Table.

Returns

  • encoded
    String.

Notes

Available since 20250313.

Example

form = http.table_to_form_urlencoded{
num = 1,
str = '你好',
arr = {12, 34, '好'},
}

nLog(form) -- arr%5B0%5D=12&arr%5B1%5D=34&arr%5B2%5D=%E5%A5%BD&str=%E4%BD%A0%E5%A5%BD&num=1

c, h, r = http.get('https://httpbin.org/get?'..form, 10, {}, true)
nLog(r)

c, h, r = http.post('https://httpbin.org/post', 10, {}, form)
nLog(r)