Re: [json-lib-user] XML -> JSON, "type" attribute omitted?
Brought to you by:
aalmiray
|
From: Andres A. <aal...@ya...> - 2007-12-05 23:50:11
|
Hi John,
No, in this case seems to be something else, perhaps corner case where XMLSerializer can't decide if FEATURES should be a JSONObject instead of a JSONArray. To me it should be something like
{
RESPONSE:
{
FEATURES:
{
...
}
}
}
Are you getting this result with Json-lib 2.1 ?
-- Andres
----- Original Message ----
From: John Cartwright <Joh...@no...>
To: Andres Almiray <aal...@ya...>
Cc: jso...@li...
Sent: Wednesday, December 5, 2007 3:42:47 PM
Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted?
Hi Andres,
is it possible that an XML element named features would have the same
trouble? I'm finding the XML listed below is serializing to JSON w/o
that element.
Thanks!
-- john
<?xml version="1.0" encoding="UTF-8"?>
<ARCXML version="1.1">
<RESPONSE>
<FEATURES>
<FEATURE>
<ENVELOPE minx="-178.216552734375" miny="18.9254779815674"
maxx="179.775939941406" maxy="71.3514404296875"/>
<FIELDS>
<FIELD name="FIPS_CNTRY" value="US" />
<FIELD name="GMI_CNTRY" value="USA" />
<FIELD name="ISO_2DIGIT" value="US" />
<FIELD name="ISO_3DIGIT" value="USA" />
<FIELD name="CNTRY_NAME" value="United States" />
<FIELD name="LONG_NAME" value="United States" />
<FIELD name="SOVEREIGN" value="United States" />
<FIELD name="POP_CNTRY" value="258833000" />
<FIELD name="CURR_TYPE" value="US Dollar" />
<FIELD name="CURR_CODE" value="USD" />
<FIELD name="LANDLOCKED" value="N" />
<FIELD name="SQKM" value="9449365" />
<FIELD name="SQMI" value="3648399.75" />
<FIELD name="COLORMAP" value="5" />
<FIELD name="#SHAPE#" value="[Geometry]" />
<FIELD name="#ID#" value="234" />
</FIELDS>
</FEATURE>
<FEATURECOUNT count="1" hasmore="false" />
<ENVELOPE minx="-178.216552734375" miny="18.9254779815674"
maxx="179.775939941406" maxy="71.3514404296875"/>
</FEATURES>
</RESPONSE>
</ARCXML>
{"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United
States"},{"@name":"LONG_NAME","@value":"United
States"},{"@name":"SOVEREIGN","@value":"United
States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US
Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"}
Andres Almiray wrote:
> Hi John,
>
> Sorry for the late reply. The answer is yes and no, let me explain.
> XMLSerializer has an option to expose a value's type when serializing
> JSON to XML, that information is written as an attribute named
'type'.
> When reading it is assumed you want to recover that information if
> 'type' is an attribute of a node, but it seems that in your case type
> has a business meaning and should be treated like that instead of a
> construct of the library. The same will happen with an attributed
> named 'class' by the way.
>
> Let me look for an alternative that is backward compatible at the
same
> time.
>
> Cheers,
> Andres
>
> -------------------------------------------
> http://jroller.com/page/aalmiray
> http://www.linkedin.com/in/aalmiray
> --
> What goes up, must come down. Ask any system administrator.
> There are 10 types of people in the world: Those who understand
> binary, and those who don't.
> To understand recursion, we must first understand recursion.
>
>
> ----- Original Message ----
> From: John Cartwright <Joh...@no...>
> To: jso...@li...
> Sent: Monday, October 8, 2007 10:29:37 AM
> Subject: [json-lib-user] XML -> JSON, "type" attribute omitted?
>
> Hello All,
>
> It seems to me that when converting XML to JSON, elements w/ an
> attribute named "type" have that attribute omitted. Is this expected
> behavior?
>
> Thanks!
>
> -- john
>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> json-lib-user mailing list
> jso...@li...
> https://lists.sourceforge.net/lists/listinfo/json-lib-user
>
>
>
------------------------------------------------------------------------
> Catch up on fall's hot new shows
>
<http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20>
> on Yahoo! TV. Watch previews, get listings, and more!
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs |