I'm not sure what you're trying to accomplish but only the input which is checked is going to be included by serializeArray()
. You can read more about it here.
But your array is being returned as an object as it should. To see the layout of the JSON of this object you could try JSON.stringify(attr_str)
.
var attr_str = $('input').serializeArray();
attr_str.push({q:'hello',p:'world'});
$('body').append('<br><br>string='+JSON.stringify(attr_str));
This will show that you are appending an object into yourattr_str
array but only input 'b' is included because it is the only one that is checked. string=[{"name":"b","value":"on"}{"q":"hello","p":"world"}]
To access this object you would simply use attr_str[0]
then for a property of that object use attr_str[0].name
. Which would print b
.