My JSON data is as follows:
$scope.myjson = [
{id: "1", name: "a"},
{id: "2", name: "b"},
{id: "3", name: "c", children: [{id: "4", name: "d"}]}
];
I am looking to store the position of object X in JavaScript, such as the first object at $scope.myjson[0]
, without saving the actual object itself. Similarly, I want to save $scope.myjson[2].children[0]
.
Should I save it as a string? How can I retrieve that object in O(1) time once saved?