I'm currently working with d3.js and struggling to grasp how I can effectively load a JSON file representing a table that has separate column definitions.
A typical JSON file, which I have no issue loading, might appear like this:
[
{
"id": 1,
"name": "A green door",
"price": 12.50
},
{
"id": 2,
"name": "A red door",
"price": 12.50
},
{
"id": 3,
"name": "A blue door",
"price": 12.50
}
]
On the other hand, a JSON file with separated columns would look something like this:
{
"columns": [
{
"ColumnName":"id",
"DataType":"number"
},
{
"ColumnName":"name",
"DataType":"string"
},
{
"ColumnName":"price",
"DataType":"number"
}
],
"rows": [
[
"1",
"A green door",
"12.50"
],
[
"2",
"A red door",
"12.50"
],
[
"3",
"A blue door",
"12.50"
]
]
}
Is there a way for d3.js to directly load this type of JSON without needing to modify its structure?
Unfortunately, the original format of the JSON data cannot be altered.
Your assistance is greatly appreciated.