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
Nested array within an Array Object #88
Comments
There are something wrong in your code :
|
Thanks for the quick reply @cappuccinoqi! Your suggestion wasn't the exact output I was looking for, but tinkering with it some more based on your guidance I got it work using the following structure
That results in
|
aha , I did this in a hurry, perhaps it was because Chrome Debug Mode doesn't show the result well.Good to hear that my suggestion is useful. |
@randallmlough If you don't mind ,would you like to tell me how can you get that result ? My output in Chrome is not tidy as your result. |
Using the To avoid confusion, I recommend explicitly specifying the array indexes (use <input type="text" name="staff[0][name]" value="john doe" />
<input type="text" name="staff[0][another_array][0]" value="something" />
<input type="text" name="staff[0][another_array][1]" value="something2" />
<input type="text" name="staff[0][array_obj][0][title]" value="something" />
<input type="text" name="staff[0][array_obj][0][desc]" value="foobar" /> And then use serializeJSON with the option useIntKeysAsArrayIndex: $('input').serializeJSON({useIntKeysAsArrayIndex: true}); This way you get exactly what you would expect: {
"staff": [{
"name": "john doe",
"another_array": [
"something",
"something2"
],
"array_obj": [{
"title": "something",
"desc": "foobar"
}]
}]
} |
I was hoping to figure out how I can have an array or an array object within another array object.
my desired output
I've tried something like
and something like...
But none of the above works. It doesnt appear you can have nested arrays. Is this true?
The text was updated successfully, but these errors were encountered: