I am using JavaScript JSON object. I am not sure this is the right way to write JSON object :-
var address={
details:{
"martin":[{"full_name":"James Martin"},{"address":"Florida"},{"phone":"897657834"}],
"luthar":[{"full_name":"Luther king"},{"address":"Boston"},{"phone":"9856568789"}],
"jonson":[{"full_name":"Jonson vierra"},{"address":"New york"},{"phone":"98654567887"}]
}
}
Now, I want to show every elements of each person in a table. I can do this manually by writing:
<table border=1>
<tr>
<td><script>document.write(address.details.martin[0].full_name)</script></td>
<td><script>document.write(address.details.martin[1].address)</script></td>
<td><script>document.write(address.details.martin[2].phone)</script></td>
</tr>
</table>
Like this for all 3 people, but I want to grab full details of every person by using a loop. How can I do this easily by using a loop?
detailsisn't enclosed in quotes, but it's not clear why you want JSON rather than just an object literal anyway.