openresty / openresty/lua-nginx-module
Lua parse json value from request_body
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
Hello, i'm receiving POST to my lua endpoint.
That post body it's with json body.
I need to cut off one object from json post body
The body that is coming is looking like this :
{
"param1": "1033893",
"param2": "337483",
"param3": "test",
}
I want to cut only param2 (only numbers) and put it as a value because I need to compare it with one file content
I'm using this local :
local check_body = ngx.req.get_body_data()
In bash script I normally run this :
echo $CURL_post_request | cut -d\| -f 1| grep -m1 -oP '\s*"param2"\s*:\s*\K[^,]+'| tr -d '"'| tr -d '}'
But in lua I'm not sure how I can fix this
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mentioned ngx.req.get_body_data() entry point and review how this project handles JSON request bodies in Lua. Confirm how param2 can be obtained as a numeric value from the posted body and compared with file content; done means the extraction approach is documented or demonstrated clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, nginx
- Domain
- api, backend
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100