marioizquierdo / jquery.serializeJSON

Serialize an HTML Form to a JavaScript Object, supporting nested attributes and arrays.
MIT License
1.72k stars 431 forks source link

Feature request #87

Closed stratboy closed 6 years ago

stratboy commented 6 years ago

hi, thank you very much for your code. I'd suggest a new feature: add data-attributes to json output. That would be useful to add custom strings to fields and values. For example, we often need to bind some string to some field to make up some mail message (ex. the 'name' field will probably be rendered in mail message like 'Name'). It would make possible to build server-side scripts that almost automate email message building.

Thank you very much

marioizquierdo commented 6 years ago

Hi. Don't you think it would be simpler to just modify the serialized JSON object with JavaScript code before sending it down to the server? Or maybe I don't understand the request well. Could you provide a little more context or one example?

stratboy commented 6 years ago

Hi, yes maybe you're right. And I'm quite sure I was wrong in my intent: to have fields labels defined in data attributes. I found out it's a bad practice since people could easily change them from console and then mess up the resulting mail message. So thank you, anyway :)