PostgreSQL13 jsonb_pretty関数でjson文字列を返すサンプル

環境
Windows 10 Home 64bit
PostgreSQL 13.2, compiled by Visual C++ build 1914, 64-bit

書式
jsonb_pretty(from_json jsonb)
jsonb_pretty関数を使って、from_jsonをインデントしたJSON文字列にして返す。

SQL構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
select jsonb_pretty('[{"age":12,"name":"tokyo"},2,null,3]')
select jsonb_pretty('[{"age":12,"name":"tokyo"},2,null,3]')
select jsonb_pretty('[{"age":12,"name":"tokyo"},2,null,3]')

結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[
{
"age": 12,
"name": "tokyo"
},
2,
null,
3
]
[ { "age": 12, "name": "tokyo" }, 2, null, 3 ]
[
    {
        "age": 12,
        "name": "tokyo"
    },
    2,
    null,
    3
]

 

PostgreSQL

Posted by arkgame