Skip Menu |
 

This queue is for tickets about the XML-XML2JSON CPAN distribution.

Report information
The Basics
Id: 43193
Status: stalled
Priority: 0/
Queue: XML-XML2JSON

People
Owner: perl [...] xev.net
Requestors: SHAFTEK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.05
Fixed in: (no value)



Subject: json2xml chokes on Google AJAX Search API output
Download (untitled) / with headers
text/plain 767b
When trying to convert JSON output from Google AJAX API to XML using the xml2json method, I get an error message as follows: Invalid data for key: responseDetails Here is the dump from my program when I enable debug mode: Converting json to obj using JSON::Syck at ./search.pl line 72 Key type for responseDetails is: (value seems to be ) at /kunden/homepages/29/d87905022/htdocs/lib/perl5/XML/XML2JSON.pm line 701, <STDIN> line 1. Invalid data for key: responseDetails The conversion to XML works just fine when using the XMLout method of the XML::Simple class (it is used in Google::Data::JSON class). I attached a copy of the Google's JSON response. You can see a live copy by running: curl "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=perl"
Subject: test.json
Download test.json
text/x-json 2.6k
{"responseData": {"results":[{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://www.perl.org/","url":"http://www.perl.org/","visibleUrl":"www.perl.org","cacheUrl":"http://www.google.com/search?q\u003dcache:yFsp4qVWuT0J:www.perl.org","title":"The \u003cb\u003ePerl\u003c/b\u003e Directory - \u003cb\u003eperl\u003c/b\u003e.org","titleNoFormatting":"The Perl Directory - perl.org","content":"The \u003cb\u003ePerl\u003c/b\u003e Directory at \u003cb\u003eperl\u003c/b\u003e.org. Links and other helpful resources for new and experienced \u003cb\u003ePerl\u003c/b\u003e programmers."},{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://www.perl.com/","url":"http://www.perl.com/","visibleUrl":"www.perl.com","cacheUrl":"http://www.google.com/search?q\u003dcache:KR_pUC29AmoJ:www.perl.com","title":"\u003cb\u003ePerl\u003c/b\u003e.com Home Page","titleNoFormatting":"Perl.com Home Page","content":"News site run by O\u0026#39;Reilly. Contains documentation, weekly articles, \u003cb\u003ePerl\u003c/b\u003e development summaries, blogs, and links to a variety of resources."},{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://en.wikipedia.org/wiki/Perl","url":"http://en.wikipedia.org/wiki/Perl","visibleUrl":"en.wikipedia.org","cacheUrl":"http://www.google.com/search?q\u003dcache:_6WLxd7tqGYJ:en.wikipedia.org","title":"\u003cb\u003ePerl\u003c/b\u003e - Wikipedia, the free encyclopedia","titleNoFormatting":"Perl - Wikipedia, the free encyclopedia","content":"In computer programming, \u003cb\u003ePerl\u003c/b\u003e is a high-level, general-purpose, interpreted, dynamic programming language. \u003cb\u003ePerl\u003c/b\u003e was originally developed by Larry Wall, \u003cb\u003e...\u003c/b\u003e"},{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://www.cpan.org/","url":"http://www.cpan.org/","visibleUrl":"www.cpan.org","cacheUrl":"http://www.google.com/search?q\u003dcache:p7xGKrz4dSMJ:www.cpan.org","title":"CPAN","titleNoFormatting":"CPAN","content":"Comprehensive \u003cb\u003ePerl\u003c/b\u003e Archive Network. 2009-02-10 online since 1995-10-26 5213 MB 220 mirrors \u003cb\u003e...\u003c/b\u003e Welcome to CPAN! Here you will find All Things \u003cb\u003ePerl\u003c/b\u003e. \u003cb\u003e...\u003c/b\u003e"}],"cursor":{"pages":[{"start":"0","label":1},{"start":"4","label":2},{"start":"8","label":3},{"start":"12","label":4},{"start":"16","label":5},{"start":"20","label":6},{"start":"24","label":7},{"start":"28","label":8}],"estimatedResultCount":"92600000","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dperl"}}, "responseDetails": null, "responseStatus": 200}
Download (untitled) / with headers
text/plain 967b
On Tue Feb 10 20:56:09 2009, SHAFTEK wrote: Show quoted text
> When trying to convert JSON output from Google AJAX API to XML using the > xml2json method, I get an error message as follows: > > Invalid data for key: responseDetails > > Here is the dump from my program when I enable debug mode: > > Converting json to obj using JSON::Syck at ./search.pl line 72 > Key type for responseDetails is: (value seems to be ) at > /kunden/homepages/29/d87905022/htdocs/lib/perl5/XML/XML2JSON.pm line > 701, <STDIN> line 1. > Invalid data for key: responseDetails > > The conversion to XML works just fine when using the XMLout method of > the XML::Simple class (it is used in Google::Data::JSON class). > > I attached a copy of the Google's JSON response. You can see a live copy > by running: > > curl "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=perl"
It looks like the module isn't handling "null" values correctly. I will fix this soon. Thanks for the bug report.
Download (untitled) / with headers
text/plain 322b
I don't want to stall this indefinitely but this has just sat open for too long. This module was always meant to turn XML into JSON (not the other way around.) Any JSON created by this module can be turned back into XML, but getting it to turn JSON from external sources into XML will require large changes to this module.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.