Skip to content

Attempts to parse the body of a Plumber req object. Supports both req$body (already parsed) and req$bodyRaw (raw binary). If the body looks like JSON ({...} or [...]), it tries to parse it with jsonlite::fromJSON. Otherwise, it returns the raw text.

Usage

whapi_parse_body(req)

Arguments

req

A Plumber request object (list-like).

Value

A list representing the parsed body, or NULL if no body is found.

Examples

# Inside a Plumber endpoint:
# parsed <- whapi_parse_body(req)
# if (!is.null(parsed)) str(parsed)