'PostgreSQL - Delete last item of JSONB array

I have a field that holds JSONB arrays. How can I delete the last item?

[
  {
    "name": "test1",
  },
  {
    "name": "test2",
  },
]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source