Looking to convert a dynamic JSON structure into a tree node:
{
"video": {
"width": 1920,
"height": 1080,
"video_codec": "H264",
"CBR": "4337025",
"frame_rate": {
"numerator": 25,
"denominator": 1
},
"specified": {
"numerator": 1,
"denominator": 1
},
"gop": {
"length": 50,
"reference_frames": 3,
"sub_gop": "StaticType"
},
"codec_details": {
"profile": "Main",
"level": "Level4",
"entropy_encoding": "CABAC",
"video_output": "AVC1"
}
}
}
Desired tree node structure:
export class TrackDetailsNode {
key: string;
value: string;
children?: TrackDetailsNode[];
}
Example of the expected output:
{
"key": "video",
"children": [
{
"key": "width",
"value": "1920"
},
{
"key": "frameRate",
"children": [
{
"key": "numerator",
"value": "60"
},
{
"key": "denominator",
"value": "1"
}
]
}
]
}
Looking for a recursive approach to efficiently parse and build the tree structure from the JSON provided.