My apex controller returns this JSON object with the name of the product:id ( if we have no id is that the product is unvalid.


I'd like to know if it's possible to generate a table with javascript that looks like:

| name | status |

ske-95 | unvalid

sdf-5022| valid


  • are you using remote action to return above json object?
    – Himanshu
    Nov 25, 2015 at 14:19
  • @Himanshu no I'm using an actionfunction
    – Joey Pablo
    Nov 25, 2015 at 14:26

1 Answer 1


The JSON format (assuming the backslashes are not actually present) you have is not ideal because although you can use a for...in loop over those values in JavaScript the ordering will be arbitrary which is probably not what you want. An array of objects would make more sense so you could loop over the elements in index order:


You can create arrays/lists and maps in Apex to achieve the ordering you need when you JSON.serialize.

For such a simple table, to create the table in JavaScript you don't need anything more than the raw DOM methods to add the table, table rows and table cells.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .