hx-vals + json-enc: first-level empty array is dropped
htmx.org 2.0.10, json-enc 2.0.3.
This bug breaks some cases of the programmatic population of `hx-vals`. E.g. as in the example from the [docs](https://htmx.org/attributes/hx-vals/): `hx-vals='js:{...foo()}'` where `foo()` returns a map where some first-level value is `[]`.
`
## Steps
See https://jsfiddle.net/r4sgw3nh:
```html
<script src="https://unpkg.com/htmx.org@2.0.10"></script>
<script src="https://unpkg.com/htmx-ext-json-enc@2.0.3/json-enc.js"></script>
<button type="button" hx-ext="json-enc" hx-post="/test" hx-vals='js:{
"firstLevel": [],
"secondLevel": {
"values": []
}
}'>
Click me
</button>
```
1) Click `Click me`.
2) Inspect the made request payload in the browser devtools.
# Actual
`{"secondLevel":{"values":[]}}`
# Expected
`{"firstLevel":[],"secondLevel":{"values":[]}}`
0 条评论