PostgreSQL 9.5: SELECT JSON Formatted data using jsonb_pretty()

Recently, PostgreSQL introduced JSON data type which is very powerful to manipulate JSON formatted data.

I have published a couple of articles on JSON Data Type.
You can start from here.

PostgreSQL 9.4: The JSON data type is Awesome (Part 1/3)

Recently, I have received a couple of comments on my FB page related use of PostgreSQL JSONB.

A JSONB data type does not preserve any white spaces. Whatever format we have specified, It removes and store without white spaces.

PostgreSQL 9.5 introduced jsonb_pretty() to get JSON formatted data.
When we are troubleshooting JSON related data at that time we require to get JSON in readable format.

Below is a small demonstration of jsonb_pretty():

Create table with sample JSON data:

Using jsonb_pretty format function:

Result:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz