-
Notifications
You must be signed in to change notification settings - Fork 351
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
Support "dot" notation for object property names #4
Comments
I don't know of any web framework that currently supports inputs like that, but you're more than welcome to add the feature. If you do choose to add this feature, I think it should be done by passing $(sel).serializeObject({nesting: "dot"}); Where default options would be: $.fn.serializeObject.defaults = {
nesting: "brackets"
}; |
I see your point - there are probably even lots of frameworks that would break if the inputs were parsed in the way I suggest (it rules out allowing periods in your input names) - then again, those frameworks are probably not designed to work with input nested in this manner in any case. I'll let you know if I get anywhere with this, thanks for the input! |
@macgyver i just wanted to follow up and let you know some things have changed that can support the dot notation now. Please see this comment from another issue. Also, please see the update API documentation. I've included this example to support dot notation. $.extend(FormSerializer.patterns, {
validate: /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+)*(?:\[\])?$/i
}); Here's a fiddle demo |
.net framework mvc uses dots as an indicator of an object |
@AndersMadsen thanks for the comment. I wasn't sure where people would prefer the dot notation. Are you having issues getting dot notation working with your .NET project? |
@AndersMadsen It's not clear whether you're actually having an issue or just making a comment. "dot" notation is supported as an "option" and is working as tested. Please let me know if you're having trouble getting this working on your own project. |
@macek sorry for being unclear, I was having an issue when i was using it that it did not create any object at all (if you look at the issue I linked) it probably will with the dot-notation. What I was thinking about was to submit hyphen and dots as options instead of regular expressions, but still keeping the flexible reg-ex option, like
The reason I'm suggesting a feature like this is for readability, I'm not a reg-ex shark (yet) so In my case I'll have read the reg-ex thoroughly before I understand what it does. |
.NET Razor engine creates lists using dot notation. The Razor serialization engine is JSON.NET - So I think this support would be great here because I am working on WebForms with MVC 5 knowledge. So building lists on the client with dot notation and submiting to a webform based on JSON.NET. Its no problem I can use the syntax as provided to build the object but just wanted to let you know that there is a major framework that uses dot notation. The fact you dont know about it is because people that use MVC do not need this plugin because its all extended in the framework and works like dream. Basically retro fitting projects like I am doing.. it would be nice to stay inline with .NET notations. Because using partial post backs and all that other form crap is a nightmare and this plugin is the closest thing to emulate the Razor implemented convention. Thanks for interesting plugin. Basically the formatter provider does not work. THis is how I name my classes for the default .NET Serializes to deserialize to a LIST of Entities in psuedo. Basiclly on load there may be bound data but you change the values with jQuery as the user goes along.
Then in webforms its as simple as. Notice "SomeName" is the variable here not the entity type!
|
If you're using compose dot and bracket (like $.extend(FormSerializer.patterns, {
validate: /^[a-z][a-z0-9_]*(?:(?:\.[a-z0-9_]+)|(?:\[[a-z0-9_]+\]))*(?:\[\])?$/i
}); I use it and using the library jsonform (https://jsonform.github.io/jsonform) work together. |
Haha, ok thanks for the update ;) |
This is a rad plugin! I personally think it would be cool if it also supported dot notation, e.g:
would parse the same as:
The text was updated successfully, but these errors were encountered: