What ia preferred in json to have nested objects or not

I have to make a simple family tree that is parent child relation. I will be using API to fetch data so should I make nested objects of json. Or should I make a foreign key in each object, what is preferred way I am very confused. Is it wrong to make too many nested objects in json?

Upvotes: 0

Views: 224

Answers (1)

Martin Heralecký
Martin Heralecký

Reputation: 5779

Nested objects are easier and faster to access, but consume a lot of memory. Foreign keys are memory-effective, but in order to access the referenced objects, you need to implement some locating algorithm.

Upvotes: 1

Related Questions