Thread: row_to_json white space

row_to_json white space

From
Mark Lybarger
Date:
Hi,  

The row_to_json seems to strip white space:

select ROW_to_json(q) from (select 'foo        a   bar' as TEST) q;

any help on how to preserve?

Thanks!
-mark-


Re: row_to_json white space

From
Rob Sargent
Date:
On 9/26/19 11:54 AM, Mark Lybarger wrote:
> select ROW_to_json(q) from (select 'foo        a   bar' as TEST) q;

Not here

postgres=# select ROW_to_json(q) from (select 'foo        a bar' as TEST) q;
           row_to_json
-------------------------------
  {"test":"foo        a   bar"}
(1 row)

postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
  PostgreSQL 10.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 
20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)




Re: row_to_json white space

From
Adrian Klaver
Date:
On 9/26/19 10:54 AM, Mark Lybarger wrote:
> Hi,
> 
> The row_to_json seems to strip white space:
> 
> select ROW_to_json(q) from (select 'foo        a   bar' as TEST) q;
> 
> any help on how to preserve?

Like Rob I do not see it:

test=# select version();
                                       version 

------------------------------------------------------------------------------------
  PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux) 
4.8.5, 64-bit
(1 row)

test=# select ROW_to_json(q) from (select 'foo        a   bar' as TEST) q;
           row_to_json
-------------------------------
  {"test":"foo        a   bar"}
(1 row)


Do you possibly have an overloaded function of the same name(ROW_to_json())?


> 
> Thanks!
> -mark-
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: row_to_json white space

From
Adrian Klaver
Date:
On 9/26/19 11:54 AM, Mark Lybarger wrote:

Ccing the list so folks know  the problem is solved.

> Problem is on my end.  My tool was showing the space removed and infact 
> it wasn't.  Copy paste from dbeaver to notepad++ shows the spaces are 
> preserved.
> 
> On Thu, Sep 26, 2019 at 2:49 PM Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 9/26/19 10:54 AM, Mark Lybarger wrote:
>      > Hi,
>      >
>      > The row_to_json seems to strip white space:
>      >
>      > select ROW_to_json(q) from (select 'foo        a   bar' as TEST) q;
>      >
>      > any help on how to preserve?
> 
>     Like Rob I do not see it:
> 
>     test=# select version();
>                                             version
> 
>     ------------------------------------------------------------------------------------
>        PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux)
>     4.8.5, 64-bit
>     (1 row)
> 
>     test=# select ROW_to_json(q) from (select 'foo        a   bar' as
>     TEST) q;
>                 row_to_json
>     -------------------------------
>        {"test":"foo        a   bar"}
>     (1 row)
> 
> 
>     Do you possibly have an overloaded function of the same
>     name(ROW_to_json())?
> 
> 
>      >
>      > Thanks!
>      > -mark-
>      >
>      >
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com