JSFiddle - React, Tailwind, and code Playground

by mavdhana

JavaScript

var jsondata = [
{"id": "1","name": "test1","sub_values": [{"id": "1","name": "Test1","sub_values": []}]},
{"id": "2","name": "test2","sub_values": [{"id": "1","name": "Test5","sub_values": []},{"id": "1","name": "Test10","sub_values": []},{ "id": "1","name": "Test20","sub_values": []}]},
{"id": "3","name": "test3","sub_values": [{"id": "1","name": "Test50","sub_values": []}]}
];

console.log(jsondata);//(3) [Object, Object, Object] 
console.log(jsondata.sub_values.name);//Cannot read property 'name' of undefined 
console.log(jsondata.sub_values.length);//Cannot read property 'length' of undefined