Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 107F964FD69 for ; Fri, 21 Nov 2008 02:54:40 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54022-07 for ; Fri, 21 Nov 2008 02:54:37 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mail.postgresql.org (Postfix) with ESMTP id 32FB264FD5E for ; Fri, 21 Nov 2008 02:54:36 -0400 (AST) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 9875C1C1296 for ; Fri, 21 Nov 2008 01:54:35 -0500 (EST) Received: from web5.messagingengine.com ([10.202.2.214]) by compute1.internal (MEProxy); Fri, 21 Nov 2008 01:54:35 -0500 Received: by web5.messagingengine.com (Postfix, from userid 99) id 7E48D2C423; Fri, 21 Nov 2008 01:54:35 -0500 (EST) Message-Id: <1227250475.15555.1285991741@webmail.messagingengine.com> X-Sasl-Enc: RabKq7udImhEIzQcKHlUdE1fNVs8NMZl4A3JGWSPRM3q 1227250475 From: "V S P" To: pgsql-php@postgresql.org Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="KOI8-R" MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface Subject: [Q] storing JSON, problem with 'escapes' Date: Fri, 21 Nov 2008 01:54:35 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200811/18 X-Sequence-Number: 3929 Hi, I am using PHP's json_encode function on an array of strings that gives me back a JSON encoded string. Some of the elements in the string arrays have double quotes. So PHP's json_encode correctly escapes them (according to JSON specifications) with \. For example here is a an array element "if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK("b2122") ;}" would get encoded in JSON as "if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK(\"b2122\") ;}" And that's correct. Now, the problem is that with PDO (or may be postgresql itself) I get "if( js_iop_lt(a,b) ){ VLADIKVLADIKVLADIKVLADIK(\\"b2122\\") ;}" and I get then the POSTGRESQL warning WARNING: nonstandard use of \\ in a string literal at character 240 HINT: Use the escape string syntax for backslashes, e.g., E'\\'. ( I am seeing what postgres is getting because I enabled logging of all the statements to stderr) -------- So I am not sure what to do. This has to be a common issue (unless nobody before me stored JSON in postgresql :-) ). The PDO does not provide facilities to 'not to escape' or escape differently. Ideally I do not want the second backslash. I do not undestand who adds it and why. The first backslash is by json_encode -- which is correct. thanks in advance for any help. -- V S P toreason@fastmail.fm -- http://www.fastmail.fm - Access all of your messages and folders wherever you are