Anyone know how to convert an HTML table of values into a nice JSON object to be manipulated with jQuery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An HTML table? Like, all the
<td>contents in a 2-d array?Then just use $.json (or whatever library you want) to turn that into a JSON string.
edit — re-written to use the native (shim here)
.map()from the array prototype:The jQuery
.map()function has the “feature” of flattening returned arrays into the result array. That is, if the callback function returns a value that is itself an array, then instead of that returned array becoming the value of one cell of the.map()result, its elements are each added to the result.It might work to use the original jQuery version and just wrap an extra array around the returned values.