Is there a really easy way I can take an array of JSON objects and turn it into an HTML table, excluding a few fields? Or am I going to have to do this manually?
相关问题
- Is there a limit to how many levels you can nest i
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to toggle on Order in ReactJS
- StackExchange API - Deserialize Date in JSON Respo
Pure HTML way, not vulnerable like the others AFAIK:
Example usage:
Pivoted single-row view with headers on the left based on @Dr.sai's answer above.
Injection prevented by jQuery's .text method
Converting a 2D JavaScript array to an HTML table
To turn a 2D JavaScript array into an HTML table, you really need but a little bit of code :
Loading a JSON file
If you want to load your 2D array from a JSON file, you'll also need a little bit of Ajax code :
I'm not sure if is this that you want but there is jqGrid. It can receive JSON and make a grid.
Using jQuery will make this simpler.
The following will take an array of arrays and store convert them into rows and cells.
You could add a check for the keys you want to exclude by adding something like
at the start of the getJSON cbf and adding
around the tbl_row += line.
Edit: Was assigning a null variable previously
Edit: Version based on Timmmm's injection-free contribution.
with pure jquery: