[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-bugs
Subject:    Re: [BUGS] BUG #12320: json parsing with embedded double quotes
From:       Francisco Olarte <folarte () peoplecall ! com>
Date:       2014-12-23 18:17:05
Message-ID: CA+bJJbz0-KdKeBZ9JzyzJDcVkZ5bHimH-TfSsz4hjGQNpm65Fw () mail ! gmail ! com
[Download RAW message or body]

Hi Aaron:
....

>
> user:\"root\""}}}}},"from":0,"size":20,"timeout":10000,"sort":{"timestamp":{"order":"

.....

Copy from does it's own round of backslash scaping, if you look at

http://www.postgresql.org/docs/9.4/static/sql-copy.html

The third paragraph under File formats / text format reads:

Backslash characters (\) can be used in the COPY data to quote data
characters that might otherwise be taken as row or column delimiters. In
particular, the following characters must be preceded by a backslash if
they appear as part of a column value: backslash itself, newline, carriage
return, and the current delimiter character.

As you want the backslash as part of the data you need to double it in the
file, otherwise you'll fall into the later case:
.....Any other backslashed character that is not mentioned in the above
table will be taken to represent itself

And the backslash will get eaten and the json parser will fail. It's the
same problem that you get when you try to put windows paths or perl type
regular expresions inside doube quoted C/Java/perl/shell/and_many_more
Strings.

If your table is always a single column and you cannot edit the file, you
can always try to change the scape character.

Regards.
    Francisco Olarte.

[Attachment #3 (text/html)]

<div dir="ltr">Hi Aaron:<br>.... <br><div class="gmail_extra"><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> \
user:\&quot;root\&quot;&quot;}}}}},&quot;from&quot;:0,&quot;size&quot;:20,&quot;timeou \
t&quot;:10000,&quot;sort&quot;:{&quot;timestamp&quot;:{&quot;order&quot;:&quot;</blockquote><div>.....<br><br></div><div>Copy \
from does it&#39;s own round of backslash scaping, if you look at \
<br></div><div><br><a \
href="http://www.postgresql.org/docs/9.4/static/sql-copy.html">http://www.postgresql.org/docs/9.4/static/sql-copy.html</a><br><br></div><div>The \
third paragraph under File formats / text format reads:<br><p>Backslash characters \
(<tt class="">\</tt>) can be  used in the <tt class="">COPY</tt> data to quote data
    characters that might otherwise be taken as row or column
    delimiters. In particular, the following characters
    <span class="">must</span> be preceded by a
    backslash if they appear as part of a column value: backslash
    itself, newline, carriage return, and the current delimiter
    character.</p><p>As you want the backslash as part of the data you need to double \
it in the file, otherwise you&#39;ll fall into the later \
case:<br></p></div><div>.....Any other backslashed character that is not mentioned in \
the  above table will be taken to represent itself<br><br></div><div>And the \
backslash will get eaten and the json parser will fail. It&#39;s the same problem \
that you get when you try to put windows paths or perl type regular expresions inside \
doube quoted C/Java/perl/shell/and_many_more Strings.<br><br></div><div>If your table \
is always a single column and you cannot edit the file, you can always try to change \
the scape character.<br><br></div><div>Regards.<br></div><div>       Francisco \
Olarte.<br></div></div><br></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic