Having trouble parsing json data with d3. Below is the json structure:
{
"name": "Main Course",
...
}//json data continues
I would like to generate a list based on this data, structured as follows:
<ul>
<li>Main Course</li>
<ul>
<li>Chinese</li>
<ul>
<li>Noodles</li>
<li>Rice</li>
<li>Xinjiang Roast</li>
</ul>
<li>Indian</li>
<ul>
<li>Rice</li>
<li>Paratha</li>
<li>Dal Fry</li>
</ul>
</ul>
</ul>
However, I am facing difficulties in my current approach:
d3.select("body")
.append("ul")
// More d3 code...
The result of my implementation so far is:
<ul>
<li id="mylist">Main Course<ul> ... </ul></li>
</ul>
I believe my issue lies in accessing the children nodes correctly. How can I effectively iterate through all the child elements and nest them under their respective parent nodes?