pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastien Flaesch <sebastien.flaesch@4js.com>
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: JSON / ASP.NET AJAX Dates support in PostgreSQL
Date: Thu, 13 Apr 2023 14:44:45 +0000
Message-ID: <DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> (raw)

Hello,

Is there an easy way to convert JSON data containing ASP.NET AJAX Dates into PostgreSQL timestamp?

I have this kind of JSON data:

{
    "PurchaseOrder" : "4500000000",
    "CreationDate" : "\/Date(1672358400000)\/",
    "LastChangeDateTime" : "\/Date(1672692813062+0100)\/"
}

Warning: Note the backslash before the slashes!
According to JSON spec this is valid JSON and used by AJAX Date format.


When loading that data in Firefox, the JSON visualizer shows AJAX Date values as

"/Date(1672358400000)/"

and

"/Date(1672692813062+0100)/"

(without the backslash)

My understanding is that backslash + slash = slash in JSON strings.


How can I load this record into a table defined as:

CREATE TABLE custorder (
    "PurchaseOrder" BIGINT NOT NULL PRIMARY KEY,
    "CreationDate" TIMESTAMP NOT NULL,
    "LastChangeDateTime" TIMESTAMP NOT NULL
)

?


Seb

view thread (9+ messages)  latest in thread

Message-ID: <DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
Permalink:  ../DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sebastien.flaesch@4js.com
  Subject: Re: JSON / ASP.NET AJAX Dates support in PostgreSQL
  In-Reply-To: <DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
  References: <DBAP191MB12896A817739B869A781C00CB0989@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox