<tr class="" style="display: table-row;">
<td id="" name="">id</td>
<td id="" name="">name</td>
<td id="">hobbies</td>
<td id="">age</td>
<td id="">gender</td>
</tr>
<tr class="" style="display: table-row;">
<td id="" name="">015-08-0003-000-04</td>
<td id="" name="">john</td>
<td id=""><span id="sports" class="" title="">basketball</span>,<span id="music" class="" title="">guitar</span></td>
<td id="">21</td>
<td id="">male</td>
<td><a href="#" class="af_arpta_propertybuilding_addlandref">Add</a></td>
</tr>
This is my table for getting personal information(dynamic table). I want to create an array out of this data. I created a single array out of this like this
var $rows2 = $('#tableid').find("tr:not(:eq(0))");
$rows2.each(function () {
var $tds = $(this).find('td');
var id = $tds.eq(0).text();
var name = $tds.eq(1).text();
var hoobies = $tds.eq(2).text();
var age = $tds.eq(3).text();
var gender = $tds.eq(4).text();
perinfo.push({
id: id,
name: name,
age: age,
gender: gender
});
My problem is how to get the hobbies i want to create another entry after gender named hobbies but this time it will be multidimensional to cover sports and music category. Any suggestion to create that array out of this one.
I am hoping it would look like
[{
"id": "015-08-0003-000-04",
"name": "john",
"age": "21",
"gender": "male"
"hobbies": [{
"sport": "basketball",
"music": "guitar"
}]
}]