Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pndQz-0001hB-T2 for pgsql-general@arkaria.postgresql.org; Sat, 15 Apr 2023 10:47:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pndQy-0003KN-Oq for pgsql-general@arkaria.postgresql.org; Sat, 15 Apr 2023 10:47:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pndQy-0003K6-Dw for pgsql-general@lists.postgresql.org; Sat, 15 Apr 2023 10:47:08 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pndQu-0003TL-HK for pgsql-general@lists.postgresql.org; Sat, 15 Apr 2023 10:47:07 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 22104436C3; Sat, 15 Apr 2023 12:46:59 +0200 (CEST) Date: Sat, 15 Apr 2023 12:46:59 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: JSON / ASP.NET AJAX Dates support in PostgreSQL Message-ID: <20230415104659.7vey676djxt36snz@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <20230414163116.ubjrzvgjtqafajcl@hjp.at> <910fb9a0-9744-0eed-58d4-648806cea02d@aklaver.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="p4izshhzvukiip2e" Content-Disposition: inline In-Reply-To: <910fb9a0-9744-0eed-58d4-648806cea02d@aklaver.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --p4izshhzvukiip2e Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2023-04-14 10:44:08 -0700, Adrian Klaver wrote: > On 4/14/23 9:31 AM, Peter J. Holzer wrote: > > On 2023-04-13 10:07:09 -0500, Ron wrote: > > > On 4/13/23 09:44, Sebastien Flaesch wrote: > > > Is there an easy way to convert JSON data containing ASP.NET AJA= X Dates > > > into PostgreSQL timestamp? > > >=20 > > > I have this kind of JSON data: > > >=20 > > > { > > > =A0 =A0 "PurchaseOrder" : "4500000000", > > > =A0 =A0 "CreationDate" : "\/Date(1672358400000)\/", > > > =A0 =A0 "LastChangeDateTime" : "\/Date(1672692813062+0100)\/" > > > } > > >=20 > > > Warning: Note the backslash before the slashes! > >=20 > > That's a Noop. According to RFC 8259, "\/" is the same as "/" (no idea > > why they even specified that - it seems quite pointless). >=20 > It is a cheat explained here: >=20 > https://weblogs.asp.net/bleroy/dates-and-json Yes, but it needs a specialized JSON parser to note that. As they write: > Of course, a parser that doesn't know about this convention will just > see a string, And not only will it just see a string, it will output a string that's indistinguishable from a string with the input "/Date(1672692813062+0100)/". So any code after the parser can't detect those extra backslashes. (This would include for example the object_hook in the Python json Decoder which gets the decoded strings, not the raw strings). hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --p4izshhzvukiip2e Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmQ6gJ4ACgkQ8g5IURL+ KF1JjxAAsdN2CFHYmewpUcI4NxcOe8I+Fk7TP54ytW/luIAhHCsA0rYkwNQCN/jA Bd2qi7Y8vopZacIWqVd4Rz3tjFfuOyJ5bWTNGExfUGP+1BWxirFMDbxzBNKL3ooE iR/KWKa+SQ2mXeNyGuMJ6KI5Z3/KUKMZ4DgunnsRF79d56qDr/I2WblsIe+WHrVY XQXHQASAFtabKxCZpx0vQUizkRl2ZP7nQlLRIddEDhSIHmd5n0ep3wr4pkms/T46 7NAfQqQYo/flJvzDmUsd2Hd43rsSUephoEbWuW4/QkR81ywTkqeeILdm75udfwVA SW1BgvtQsaT/cSfy8FmfFdt44TycMsAG3QmSmnHrjUXks9egTvlaYM+LL02tqn5G yvPvi5ZdxO/eNTjRJbtlXMNmqmljTcWaL3eakD+qjK27T49NUM7BhFmPOy/yE7w9 ffiUk5ZbCqdi41HkBuYYZ++dZKlJgyI9uZ9HjLyvSnE7xmg8MaoMmaw5gFeWmwfN 2O6DzOAug/vmbTEqfP4pJRPdtwP/zvWuQ2t/AFx5lkUUXnfUWUThC+5xxMPi36SG VOJDxh3YZCh2P0diic3bH5uWdCHPydMLDtpKCgfzJ5+hLcxQoOAV0QlU7xCmlNdj REh+Z8NBg849gIr5FDu8rSncVF6HGOFMMYhNqGo96fJhX43kUXU= =OhxM -----END PGP SIGNATURE----- --p4izshhzvukiip2e--