Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Nested attributes and optional splitting character #5

Closed
wants to merge 7 commits into from
Closed

Nested attributes and optional splitting character #5

wants to merge 7 commits into from

Conversation

pho3nixf1re
Copy link

Default splitting character is [

See discussion: #4

@digitalgears
Copy link

Thanks. This is just what I was after

@hongymagic
Copy link
Owner

Thanks for the PR, I will take a look at this in the coming days!! I've been off for a while, so my apologies for taking too long.

@Reggino
Copy link

Reggino commented Jul 14, 2014

@pho3nixf1re thanks, works great.

Too bad it hasn't been pulled in yet...

@Reggino
Copy link

Reggino commented Jul 14, 2014

One issue though, array's aren't serialized properly. E.g.

<input type="number" name="root[items][0][quantity]" value="1">
<input type="number" name="root[items][1][quantity]" value="1">

Serializes as

{
    "root": {
        "items": {
            "0": {
                "quantity": "1"
            },
            "1": {
                "quantity": "1"
            }
        }
    }
}

Where i expected

{
    "root": {
        "items": [
            {
                "quantity": "1"
            },
            {
                "quantity": "1"
            }
        ]
    }
}

@pho3nixf1re
Copy link
Author

Yes! You are correct, I'll see if I can't fix that by the end of the week. Surprised I didn't add a test for that.

@hongymagic
Copy link
Owner

I know that this project is lacking .editorconfig but the whitespaces have changed quite dramatically.

In addition, as per #4 and #9 this plugin is a mere transformation of $.serializeArray. It never intended to handle complex objects and etc. It was never supposed to split name="name.first" into a nested structure and never supposed to convert [] suffixes to arrays. Again, it simply works off whatever $.serializeArray gives and never tries too hard to convert into nested JavaScript objects.

If you require an implementation which does all that, please see: https://github.com/macek/jquery-serialize-object

@hongymagic hongymagic closed this Dec 8, 2014
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants