After looking at this reference, I am attempting to integrate similar JSON data into my webpage. The challenge I am facing is that my JSON contains nested JSON. Here is an example of how my JSON structure looks:
{
"nodes": [
{"fixed":true,"classes": null,"data": {"id": "imombr","idType":"USERNAME","visible":true },"grabbable": true,"grabbed":false,"group":null,"locked": false,"position":null},
{"fixed":true,"classes": null,"data": {"id": "stephieru_","idType":"USERNAME","visible":true },"grabbable": true,"grabbed":false,"group":null,"locked": false,"position":null}
],
"links": [
{"source":0,"target":1,"value":1},
{"source":1,"target":0,"value":1}
]
}
I am trying to extract the 'id' value from the nested data to display as text. I have made multiple attempts, but it seems like I am unable to access the 'id' property within the data. Here are the methods I have tried:
node.append("text")
.attr("dx", 12)
.attr("dy", ".35em")
.text(function(d) { return d.data[id] });
and
node.append("text")
.attr("dx", 12)
.attr("dy", ".35em")
.text(function(d) { return d.data[0] });
Unfortunately, neither of these methods seem to be effective.