giltene / wrk2

A constant throughput, correct latency recording variant of wrk
Apache License 2.0
4.23k stars 381 forks source link

feat: add lua_cjson module #142

Open xiaobiaozhao opened 6 months ago

xiaobiaozhao commented 6 months ago

post_json.lua

local cjson = require "cjson"
local json_encode = cjson.encode
local json_decode = cjson.decode
wrk.method = "POST"
wrk.body = json_encode({ ["key"] = "value" })
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded"
  1. wrk can use lua's built-in json library to do json encode&decode