Parse raw JSON
Sometimes you need to parse requests which have raw JSON in the body. ambiorix::parse_multipart() only works for ‘form-data’. That’s where webutils::parse_http() comes in.
This is a simple example revolving around how you can select columns and filter rows in the iris dataset when the request body is something like this:
{
"cols": ["Sepal.Length", "Petal.Width", "Species"],
"species": ["virginica", "setosa"]
}Run API
cdinto the13_parse_raw_json/dir:cd 13_parse_raw_json/Fire up R and restore package dependencies:
renv::restore()server.Ris the entry point. Run this command in the terminal to start the API:Rscript server.R