I've a JSONB inside a PostgreSQL table with this structure (more or less)

```json
{
  "obj1": {
    "obj2": {
      "obj3": [
        {
          "obj4": {
            "obj": "A"
          }
        },
        {
          "obj4": {
            "obj": "B"
          }
        }
      ]
    }
  }
}

```

Then my obj3 is an array of objects and I wanna the obj inside obj4 separated by comma.

Thus what I really need is something like:

```
1 | A,B
2 | C,D
3 | NULL

```

I'm using PostgreSql 14. Any help is going to be appreciate.

and I've got this

```
SELECT t.id,
       jsonb_path_query(t.b,
                        '$."obj1"."obj2"."obj3"[*]."obj4"."obj"' ::jsonpath) AS obj5
  FROM (VALUES(1,
               '{"obj1":{"obj2":{"obj3":[{"obj4":{"obj":"A"}},{"obj4":{"obj":"B"}}]}}}'
               ::jsonb), (2,
         '{"obj1":{"obj2":{"obj3":[{"obj4":{"obj":"C"}},{"obj4":{"obj":"D"}}]}}}'
         ::jsonb), (3, '{}' ::jsonb)) t(id, b);

```

[![enter image description here](https://i.stack.imgur.com/Hm4Zp.png)](https://i.stack.imgur.com/Hm4Zp.png)

```

But the json_path_query multiply the rows and remove not found results as well...

```