I have some data in JSON D3 format (specifically, flare.json). It looks like this,
json_data = {
"name":"root",
"children":[
{
"name":"435",
"children":[
{
"name":"188",
"children":[
{
"name":"198"
}
]
},
{
"name":"436",
"children":[
{
"name":"86"
},
{
"name":"115"
},
{
"name":"437"
}
]
}
(etc.). The data has n levels. I have another nested list with "value" fields for some, but not all of the json_data "name" fields. For example,
[['198',50],['86',12],[...]]
I'd like to add corresponding "value" data to the json_data where applicable. So, the end result would look like this,
json_data_updates = {
"name":"root",
"children":[
{
"name":"435",
"children":[
{
"name":"188",
"children":[
{
"name":"198", "value":50
}
]
},
{
"name":"436",
"children":[
{
"name":"86","value":12
},
{
"name":"115"
},
{
"name":"437"
}
]
}
I can use this to get the all of the name values in the json_data as a list
[root, 435, 188, 198, ...]
but am unsure how to then update the json_data to be in my desired format.