This extension encodes request parameters as JSON instead of URL-encoded form data.
<script src="/path/to/ext/json-enc.js" defer></script>Add the hx-json-enc attribute to any element to enable JSON encoding for its requests:
<div hx-post="/test" hx-json-enc>click me</div>Use hx-json-enc:inherited on a parent to apply JSON encoding to all descendant requests:
<form hx-json-enc:inherited>
<button hx-post="/a">A</button>
<button hx-post="/b">B</button>
</form>Set hx-json-enc="false" to disable it on a specific element.
- Sets
Content-Type: application/jsonon the request - Values from
hx-valsare merged in with their original types preserved