I have a JSON object representing a set of segments and I'd like to create an HTML table that compares each segment in the following format:
-------------------------------------------------------------------------------
domain group | vertical | measure | Segment 1 | Segment 2
-------------------------------------------------------------------------------
group 1 | all | users clicking | 340 | 340
| | % users opening | 10% | 10%
----------------------------------------------------------------
| cars | users clicking | 340 | 340
| | % users opening | 10% | 10%
-------------------------------------------------------------------------------
group 2 | all | users clicking | 340 | 340
| | % users opening | 10% | 10%
----------------------------------------------------------------
| cars | users clicking | 340 | 340
| | % users opening | 10% | 10%
-------------------------------------------------------------------------------
How can I create a row for each segment value that will display the value's measure and then group these by vertical and then by domain group?
JSON:
{
"set": [
{
"id": 1,
"segment_desc": "Segment 1",
"segment_summary": [
{
"section_type": "domain group",
"section_value": "group 1",
"children": [
{
"children": [
{
"format": "float",
"measure": "users clicking",
"value": 340
},
{
"format": "float",
"measure": "% users opening",
"value": 10
}
],
"section_type": "vertical",
"section_value": "all"
},
{
"children": [
{
"format": "float",
"measure": "users clicking",
"value": 340
},
{
"format": "float",
"measure": "% users opening",
"value": 10
}
],
"section_type": "vertical",
"section_value": "cars"
}
]
}
]
},
{
"id": 2,
"segment_desc": "Segment 2",
"segment_summary": [
{
"section_type": "domain group",
"section_value": "group 2",
"children": [
{
"children": [
{
"format": "float",
"measure": "users clicking",
"value": 340
},
{
"format": "float",
"measure": "% users opening",
"value": 1.24
}
],
"section_type": "vertical",
"section_value": "all"
},
{
"children": [
{
"format": "float",
"measure": "users clicking",
"value": 340
},
{
"format": "float",
"measure": "% users opening",
"value": 10
}
],
"section_type": "vertical",
"section_value": "cars"
}
]
}
]
}
]
}
EDIT: An acceptable alternative to the above table layout would be to print a row for each compared segment value without it being grouped by domain group and vertical:
domain group | vertical | measure | segment 1 | segment 2
-------------------------------------------------------------------------------
group 1 | all | users clicking | 340 | 340
-------------------------------------------------------------------------------
group 1 | all | % users opening | 10% | 10%
-------------------------------------------------------------------------------
group 1 | cars | users clicking | 340 | 340
-------------------------------------------------------------------------------
group 1 | cars | % users opening | 10% | 10%
-------------------------------------------------------------------------------
group 2 | all | users clicking | 340 | 340
I have jQuery and lodash libraries installed and either library can be used.