Timstamp to Json conversion issue

From: "Yelai, Ramkumar IN BLR STS" <ramkumar(dot)yelai(at)siemens(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Timstamp to Json conversion issue
Date: 2015-01-13 06:45:21
Message-ID: 8D15F77F211D7D4786182E1C8E679FAD1A78571E41@INBLRK77M1MSX.in002.siemens.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I have migrated my postgresql 9.2 schemas to Postgres 9.4 (only table scheme migrated not the data ). I have used the following sql to convert table output to json in 9.2.

select array_to_json(array_agg(row_to_json(R.*)))::text from ( select " ID", " TIME" from "SN_TestTable" )R;

IN 9.2, I used to get this result "[{"id":1,"time":"2015-01-13 12:09:45.348"}]"

But same code in 9.4 produce this result "[{"id":1,"time":"2015-01-13T12:09:45.348"}]" . "T" separator is added between date and time.

Seems json coversion is followed ISO8601 for the timestamp. This issue is resolved by sending "TIME" column as text instead of Timestamp without timezone.

But how do I fix this problem without converting to text.

With best regards,
Ramkumar Yelai

Siemens Technology and Services Private Limited
CT DC AA I HOUSE DEV GL4
84, Hosur Road
Bengaluru 560100, Indien
Tel.: +91 80 33136494
Fax: +91 80 33133389
Mobil: +91 9886182031
mailto:ramkumar(dot)yelai(at)siemens(dot)com
http://www.siemens.co.in/STS

Registered Office: 130, Pandurang Budhkar Marg, Worli, Mumbai 400 018. Telephone +91 22 39677000. Fax +91 22 39677075. Other Offices: Bangalore, Chennai, Gurgaon, Noida, Kolkata, Pune. Corporate Identity number:U99999MH1986PLC093854

Responses

Browse pgsql-general by date

  From Date Subject
Next Message deans 2015-01-13 09:43:26 Re: BDR Error restarted
Previous Message Michael Nolan 2015-01-13 05:27:58 Re: Re: Stuck trying to backup large database - best practice? How about a cloud service?