Skip to main content

formdata

The Yock authorsLess than 1 minuteAPIhttp

formdata.encode()

  • Prototype
---@param v table<string, string[]>
---@return string
function formdata.encode(v) end
  • Introduce

encode marshals table to form string, just like json.encode() when use it.

  • Example
print(formdata.encode({
     username = { "ansurfen" },
     password = { tostring(123456) }
}))

formdata.decode()

  • Prototype
---@param v string
---@return urlValues
function formdata.decode(v) end
  • Introduce

decode unmarshals string to formdata object.

  • Example
local data = formdata.encode({
    username = { "ansurfen" },
    password = { "root" }
})
print(data)
print(formdata.decode(data):Get("password"))
print(formdata.decode("pwd=a"):Get("password"))
print(formdata.decode(""):Get("password"))