Documentation Index
Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
Use this file to discover all available pages before exploring further.
Body Parser
Prism can parse request bodies in four formats out of the box: JSON, URL-encoded forms, XML, and multipart. ThePrismBodyParserMiddleware auto-detects the content type, and request extensions give you direct access to parsed data.
Auto-Detection Middleware
Enable Body Parsing
Content-Type and tags the request in userInfo["parsedBodyType"]:
| Content-Type | Tag |
|---|---|
application/json | "json" |
application/x-www-form-urlencoded | "form" |
multipart/form-data | "multipart" |
application/xml, text/xml | "xml" |
JSON Bodies
The most common format. UsedecodeJSON() for typed decoding:
Parse JSON
URL-Encoded Forms
Standard HTML form submissions useapplication/x-www-form-urlencoded. Access fields through formData:
Parse Form Data
Nested Forms
For complex forms with bracket notation likeuser[name]=Alice&user[address][city]=Paris:
Nested Form Parsing
Direct Nested Parsing
XML Bodies
Parse XML payloads into a traversable tree ofPrismXMLNode:
Parse XML
PrismXMLNode provides:
name— element tag nameattributes— dictionary of XML attributestext— text content of the elementchildren— child nodeschild("name")— first child with given namechildrenNamed("name")— all children with given name
XML with Attributes
XML parsing uses Foundation’s
XMLParser under the hood — fully native, no dependencies. For large XML payloads, consider streaming the body in chunks instead.