Flat structure of objects - efficient way to link up parent with child?

xyz

  • GET request’s response would be something like the following ––– meaning the concept of a category vs its sub-category is determined via parent attribute

  • I am thinking of parsing all the Category objects + filtering that collection for the ones whose parent matches the parent object’s id (that would be provided when the detail view is initiated)

  • I am sure there is a better way to do this - a linked list, perhaps? How do I go about setting that up in this context?

[
  {
    "id": 1,
    "parent": null,
    "name": "gamma"
  },
  {
    "id": 10,
    "parent": null,
    "name": "serial experiments"
  },
  {
    "id": 23,
    "parent": 1,
    "name": "alpha"
  },
  {
    "id": 88,
    "parent": 1,
    "name": "delta"
  }
]

@lganti Do you still have issues with this?

no, thanks for asking

This topic was automatically closed after 166 days. New replies are no longer allowed.