select 
  t1.id,
  array_agg(
    json_build_object('id', t2.id, 'status', t2.status)
  ) as statuses
from table1 t1
inner join table2 t2 on t1.id=t2.user_id   
inner join table3 t3 on t1.id=t3.user_id
group by t1.id
table1 
id  ,  user
1   ,  'A'
2   ,  'B'
table2
user_id  ,  status
1   ,  'P'
1   ,  'AP'
table3
user_id  ,  something
1   ,  'A12'
1   ,  'B1212'
the table3 also one-many relationship as a result the duplication of statuses coming in the array_agg, i tried with array_agg(distinct json_build_object()) and array_agg(distinct on json_build_object()), how can we prevent duplications in this case ??


[{...},{...},{...}]; What are you doing with "B1212" value?