From: Joe W. <jo...@gm...> - 2014-03-31 20:42:54
|
I agree with your assessment here, rather than your later finding. When I run your query in eXide I get this: <results> <success>{ "result": [ { "type": "/film/film", "mid": "/m/04j0hgz", "name": "Sex \u0026amp; Consequences" } ] }</success> </results> Freebase appears to have double-encoded the ampersand here. So instead of just "&" they're serving up "&amp;". Don't ask me why - but that's the way the data is. If you want to un-encode this - to get "&" - then you'll need to do further processing on the string. Joe On Mon, Mar 31, 2014 at 4:57 AM, Ihe Onwuka <ihe...@gm...> wrote: > I suspect my problem maybe related to the fact that what gets returned > is the raw unicode representation of ampersand, complete with the > leading \, because I am tokenizing that same field with \ as a > delimiter. I have to look more closely. > > On Sun, Mar 30, 2014 at 3:03 PM, Ihe Onwuka <ihe...@gm...> wrote: >> Apologies may well be due and I might have to curve that finger to >> point back at myself. >> >> This is customized from the XQuery Freebase example >> >> xquery version "3.0"; >> import module namespace xqjson="http://xqilla.sourceforge.net/lib/xqjson"; >> >> let $freebase:="https://www.googleapis.com/freebase/v1/mqlread?query=" >> >> let $queries:= >> ( >> '[{ >> "type": "/film/film", >> "mid": "/m/04j0hgz", >> "name": null >> }]' >> ) >> >> let $responses := http:send-request(<http:request >> href="{$freebase || string-join(for $q in $queries return >> encode-for-uri($q),'&')}" >> method="get"/>) >> >> return >> <results> >> {if ($responses[1]/@status ne '200') >> then >> <failure>{$responses[1]}</failure> >> else >> <success> >> {util:base64-decode($responses[2])} >> {'' (: todo - use string to JSON serializer lib here :) } >> </success> >> } >> </results> >> >> which is worth running to see the json output >> >> you can then run parse-json on the base64 decoded output and if you do >> it runs fine. >> >> I must have done something silly in my transformation that runs after >> parse-json. I will go back and look later. >> >> Sorry. >> >> >> >> On Sun, Mar 30, 2014 at 2:07 PM, Joe Wicentowski <jo...@gm...> wrote: >>> Ihe, >>> >>> Could you post the code you used? I ask because that doesn't look like standard xqjson output and want to make sure I'm seeing what you're seeing. >>> >>> Joe >>> >>> Joe >>> >>> Sent from my iPhone >>> >>>> On Mar 30, 2014, at 3:48 AM, Ihe Onwuka <ihe...@gm...> wrote: >>>> >>>> { >>>> "result": [{ >>>> "mid": "/m/04j0hgz", >>>> "name": "Sex & Consequences", >>>> "type": "/film/film" >>>> }] >>>> } >>>> >>>> Look at the name element >>>> >>>> <type>/film/film</type> >>>> <mid>/m/04j0hgz</mid> >>>> <name>Sex &amp; Consequences</name> >>>> >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Exist-open mailing list >>>> Exi...@li... >>>> https://lists.sourceforge.net/lists/listinfo/exist-open |