lightswitch05 / table-to-json

Serializes HTML tables into JSON objects.
http://lightswitch05.github.io/table-to-json/
MIT License
756 stars 172 forks source link

Facing problem on the table with multiple tr in thead #43

Closed abdulwahabplus closed 6 years ago

abdulwahabplus commented 6 years ago

This my table structure : http://plnkr.co/edit/cD3E1wcQe6HjCwMsUgxs?p=preview

I am expecting the JSON as : [{"Name":"Oscar","Age":"23","Grade":"16.5","Address":"1st street, orange city", SSN : 235345345}]

Is it possible or is there any work around...

Thanks

Mottie commented 6 years ago

Add a headings option:

$('#run').click( function() {
     var table = $('#students').tableToJSON({
       headings: ['Name', 'Age', 'Grade', 'Address', 'SSN']
     });
     alert(JSON.stringify(table));  
});

I'm not sure why the thead content is included in the results... it's been a while since I looked at the code.

abdulwahabplus commented 6 years ago

Thanks a lot for the quick response :)

I will handle it by removing first 2 rows from the result.