Skip to content
Advertisement

How to get the value of jsonb data using only the key number id?

I have a jsonb column with the following data:

I have the key number 0 that represents the first item “oz”. How can I pull this value using the 0?

I’m thinking something similar to:

I only have the key ID to reference this data. I do not have the key name “oz”.

Advertisement

Answer

Sounds like a horrible idea. But you can still create a function to implement this horrible idea:

You could also create your own operator to wrap up this disaster:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement