Anyone know how to convert a table of values into a nice JSON object to be manipulated with jquery?
EDIT: Sorry, HTML table!
Anyone know how to convert a table of values into a nice JSON object to be manipulated with jquery?
EDIT: Sorry, HTML table!
An HTML table? Like, all the <td>
contents in a 2-d array?
var tbl = $('table#whatever tr').map(function() {
return $(this).find('td').map(function() {
return $(this).html();
}).get();
}).get();
Then just use $.json (or whatever library you want) to turn that into a JSON string.
I created a jQuery plugin that I think would help you. Check out:
http://www.fletchzone.com/post/jQuery-Convert-HTML-Table-to-JSON.aspx
~Fletch