0

Bug in y.xmlToJson

When an XML payload - with attributes that don't have values (e.g. are empty) - gets converted into JSON with y.xmlToJson, the attributes end up with a {} value instead of a null value. Here's a small example; look at the y.log line:

CODE
use "http://yql.s3.amazonaws.com/ip.xml" as i; select * from i where ip="158.67.15.42"

{"results":{"Response":{"RegionCode":{},"Longitude":"8","CountryCode":"EU","RegionName":{},"CountryName":"Europe","Ip":"158.67.15.42","City":{},"Status":"OK","ZipPostalCode":{},"Gmtoffset":"1.0","Latitude":"47","Dstoffset":"2.0"}}}</log>


On the other hand - when selecting JSON as the YQL output format - the conversion is ok. In my Execute scripts, I only work with JSON and convert it back at the end to XML, so this is a painful bug.

by
3 Replies
  • QUOTE (Ivo @ Jun 24 2009, 12:44 AM) <{POST_SNAPBACK}>
    When an XML payload - with attributes that don't have values (e.g. are empty) - gets converted into JSON with y.xmlToJson, the attributes end up with a {} value instead of a null value. Here's a small example; look at the y.log line:

    CODE
    use "http://yql.s3.amazonaws.com/ip.xml" as i; select * from i where ip="158.67.15.42"

    {"results":{"Response":{"RegionCode":{},"Longitude":"8","CountryCode":"EU","RegionName":{},"CountryName":"Europe","Ip":"158.67.15.42","City":{},"Status":"OK","ZipPostalCode":{},"Gmtoffset":"1.0","Latitude":"47","Dstoffset":"2.0"}}}</log>


    On the other hand - when selecting JSON as the YQL output format - the conversion is ok. In my Execute scripts, I only work with JSON and convert it back at the end to XML, so this is a painful bug.


    We feel your pain. Thanks for reporting this issue. We'll investigate and address this issue.

    -- Nagesh
    0
  • Any news on addressing this issue?

    By the way, why not support native JSON as a y.query result output format? If this would be the case, all those format transformations wouldn't be necessary.
    0
  • QUOTE (Ivo @ Jun 29 2009, 06:43 AM) <{POST_SNAPBACK}>
    Any news on addressing this issue?

    By the way, why not support native JSON as a y.query result output format? If this would be the case, all those format transformations wouldn't be necessary.


    Ivo,

    Thanks for reporting this issue. We are going to address this for the upcoming release. Good point about y.query(..) although its happening in the same server so in essence we dont make a new request to the server (it happening inline).
    a) In addition to y.query() transformation a user would need this for y.rest(..) too so we need a general purpose method for xmlToJson
    B)-- Nagesh
    0

Recent Posts

in YQL