-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Data Type Handling in json-enc Extension #131
Comments
Hey, first of all you might be interested in the issues bigskysoftware/htmx#1870 bigskysoftware/htmx#2401 where many people shared their opinions & some implementation examples on this matter Also, depending on your preferences, you may even consider making another entirely separate extension (something like |
Transferring this issue to the extensions repo btw |
…t data type handling
To anyone coming on this issue ; see the new form-json community extension introduced in bigskysoftware/htmx#3160 |
Hello,
I’ve noticed that the
json-enc
extension currently encodes all input values as strings, even when dealing with<input type="number">
fields. This behavior can lead to incorrect data representation in the resulting JSON when numeric values are expected.To maintain backward compatibility while providing flexibility, I propose introducing an optional attribute (e.g.,
data-json-parse-data
) that allows users to opt-in to automatic type parsing. When this attribute is present on the<form>
element, the extension could:<input type="number">
into actual numbers usingNumber()
.Example usage:
Expected JSON output with
data-json-parse-data
attribute:Without the attribute, the JSON output would remain:
Would this feature be acceptable as a non-breaking enhancement? If you believe it’s a good idea, I would be happy to submit a PR for it.
Thanks in advance for your feedback!
The text was updated successfully, but these errors were encountered: