Subject: | YAML reference tags winding up in JSON data |
Sometimes YAML reference tags will wind up in JSON data. For instance,
the following code produces JSON that contains syntax errors:
perl -MJSON::Syck -MLWP::UserAgent -e 'my $ua = LWP::UserAgent->new; my
$r = $ua->get("http://www.google.com/"); print JSON::Syck::Dump($r);' >
example.txt
The resulting code is attached. note the "!perl/" sections thrown into
the middle of hash declarations.
Thanks,
Tyler
Subject: | example.txt |
{"_protocol":"HTTP/1.1","_content":"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"><title>Google</title><style><!--\n\
body,td,a,p,.h{font-family:arial,sans-serif;}\n\
.h{font-size: 20px;}\n\
.q{color:#0000cc;}\n\
//-->\n\
</style>\n\
<script>\n\
<!--\n\
function sf(){document.f.q.focus();}\n\
// -->\n\
</script>\n\
</head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf() topmargin=3 marginheight=3><center><table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td align=right nowrap><font size=-1><a href=\"/url?sa=p&pref=ig&pval=2&q=http://www.google.ca/ig%3Fhl%3Den\">Personalized Home</a> | <a href=\"https://www.google.com/accounts/Login?continue=http://www.google.ca/&hl=en\">Sign in</a></font></td></tr><tr height=4><td><img alt=\"\" width=1 height=1></td></tr></table><img src=\"/intl/en_ca/images/logo.gif\" width=276 height=110 alt=\"Google\"><br><br>\n\
<form action=/search name=f><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap><font size=-1><b>Web</b> <a id=1a class=q href=\"/imghp?hl=en&tab=wi&ie=UTF-8\">Images</a> <a id=2a class=q href=\"http://groups.google.ca/grphp?hl=en&tab=wg&ie=UTF-8\">Groups</a> <a id=4a class=q href=\"http://news.google.ca/nwshp?hl=en&tab=wn&ie=UTF-8\">News</a> <a id=7a class=q href=\"/lochp?hl=en&tab=wl&ie=UTF-8\">Local</a> <b><a href=\"/intl/en/options/\" class=q>more »</a></b></font></td></tr></table><table cellspacing=0 cellpadding=0><tr><td width=25%> </td><td align=center><input type=hidden name=hl value=en><input type=hidden name=ie value=\"ISO-8859-1\"><input maxlength=2048 size=55 name=q value=\"\" title=\"Google Search\"><br><input type=submit value=\"Google Search\" name=btnG><input type=submit value=\"I'm Feeling Lucky\" name=btnI></td><td valign=top nowrap width=25%><font size=-2> <a href=/advanced_search?hl=en>Advanced Search</a><br> <a href=/preferences?hl=en>Preferences</a><br> <a href=/language_tools?hl=en>Language Tools</a></font></td></tr><tr><td colspan=3 align=center><font size=-1>Search: <input id=all type=radio name=meta value=\"\" checked><label for=all> the web</label><input id=cty type=radio name=meta value=\"cr=countryCA\" ><label for=cty>pages from Canada</label></font></td></tr></table></form><br><font size=-1>Google.ca offered in: <a href=\"http://www.google.ca/fr\">Français</a> </font><br><br><br><font size=-1><a href=\"/ads/\">Advertising Programs</a> - <a href=/services/>Business Solutions</a> - <a href=/intl/en/about.html>About Google</a> - <a href=http://www.google.com/ncr>Go to Google.com</a></font><p><font size=-2>©2006 Google</font></p></center></body></html>","_rc":"200","_headers":{"client-response-num":1,"set-cookie":"PREF=ID=c97e3ba18b8db5ff:TM=1142023096:LM=1142023096:S=K43fgBgEdaZ76Pzp; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.ca","cache-control":"private","date":"Fri, 10 Mar 2006 20:38:16 GMT","client-peer":"66.102.7.147:80","cneonction":"Close","client-date":"Fri, 10 Mar 2006 20:38:15 GMT","content-type":["text/html","text/html; charset=ISO-8859-1"],"title":"Google","client-transfer-encoding":"chunked","server":"GWS/2.1"},"_previous":{"_protocol":"HTTP/1.1","_content":"<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n\
<TITLE>302 Moved</TITLE></HEAD><BODY>\n\
<H1>302 Moved</H1>\n\
The document has moved\n\
<A HREF=\"http://www.google.ca/\">here</A>.\r\n\
</BODY></HTML>\r\n","_rc":"302","_headers":{"client-response-num":1,"set-cookie":"PREF=ID=e049c70b7d9142ff:TM=1142023096:LM=1142023096:S=Xv5W8GYBc1orqK0i; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com","location":"http://www.google.ca/","date":"Fri, 10 Mar 2006 20:38:16 GMT","client-peer":"66.102.7.99:80","cneonction":"Close","content-length":"218","client-date":"Fri, 10 Mar 2006 20:38:15 GMT","content-type":["text/html","text/html;charset=utf-8"],"title":"302 Moved","server":"GWS/2.1"},"_msg":"Found","_request":{"_content":"","_uri":!perl/ref:{"=":"http://www.google.com/"},"_headers":{"user-agent":"libwww-perl/5.805"},"_method":"GET"}},"_msg":"OK","_request":{"_protocol":null,"_content":"","_uri":!perl/ref:{"=":"http://www.google.ca/"},"_headers":{"user-agent":"libwww-perl/5.805"},"_method":"GET"}}