bigskysoftware / bigskysoftware/htmx

json-enc only sends strings in request

Open
#1,870 11 comments 0 reactions 0 assignees View on GitHub
htmx 4
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

Hi there, I've started working recently with HTMX. I am currently writing the reactive frontend of a simple REST API. So I'm using `client-side-templates`, `json-enc`, and `mustache` for this.

I came to realize that HTMX will only support strings, no matter what input type are used in the form. This was causing some issues with Unmarshal in Go.

Here's an example of an HTML form.

```html

IMDbId

Title

IMDbRating

Release Year

Plot

Submit

```

And here's the JSON that is submitted to the server:"
```json
{"imdb_id":"tt6781235","title":"A great movie title :)","rating":"8.0","year":"2000","plot":"There is no plot to this movie..."}
```

As you can see, even the numbers are sent as strings. Solving it ended up being quite easy, but that's after I had spent some hours on debugging the issue:

Would it be an idea to add an option to parse numbers on the client before they are sent to a server (e.g. with )? Or at a minimum, add something to the documentation about this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.