You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Scott Matheson <sm...@intralinks.com> on 2013/09/02 13:14:49 UTC

JSON to XML

Hi
    We have an app based round XML, we had been giving some data in JSON. I was looking for a good tool to convert, I can see no good solution on the web

Scott


________________________________

Disclaimer: This electronic mail and any attachments are confidential and may be privileged. If you are not the intended recipient, please notify the sender immediately by replying to this email, and destroy all copies of this email and any attachments. Thank you.

Re: JSON to XML

Posted by Alexander Farber <al...@gmail.com>.
Perl is a good tool for that :-)

Re: JSON to XML

Posted by Harbs <ha...@gmail.com>.
Thanks. That's what I figured.

Unfortunately I will not be able to move completely over to JSON for everything. (XML document editing capabilities is pretty important for what I do.)

When I'm forced to start moving over to JS (probably the beginning of 2014), I'll look into this in more detail. At least I'll be able to ignore IE for my purposes (desktop), so that might make things somewhat more do-able…

On Sep 4, 2013, at 2:25 AM, Alex Harui wrote:

> 
> 
> On 9/2/13 11:56 PM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I moved over to dev because I thought it was the right place to go off on
>> this tangent...
> Ah, sorry, I wasn't tracking which list it was on.
> 
> E4x emulation seems really hard, so I'm not planning on taking it on for
> early versions of FlexJS.  IMO, there are enough folks who are building
> out JSON services that XML handling isn't a top priority.
> 
> Also, I have a hunch that doing it will be easier in the future if we can
> ever drop IE8 and assume browsers that have getter/setter support.
> 
> When I did spend a few minutes looking into XML, I think I saw that
> Flash's XMLDocument isn't easily done in JS either.  There might be some
> new API we can have everyone write to that ports well to JS, but my
> thinking is, if you have a bunch of e4x code now, re-writing that to
> XMLDocument or some new procedural API would be so painful, you would just
> as soon go to JSON.
> 
> We will probably support some sort of XMLDecoder/XMLEncoder like thing
> that translates XML to data classes or JSON trees.  It would be great to
> get some help on that if anyone is interested.  Having that and
> LazyCollections should give the best performance for those who can't use
> JSON backends.
> 
> But, of course, I could be wrong, and anyone who wants to take on better
> XML handling in FlexJS is welcome.
> 
> -Alex
> 
> 
> 
> 
>> 
>> On Sep 3, 2013, at 9:43 AM, Alex Harui wrote:
>> 
>>> Are you asking me to not reply until you've copied users@?
>>> 
>>> On 9/2/13 11:20 PM, "Harbs" <ha...@gmail.com> wrote:
>>> 
>>>> I'd like to pick up on this discussion over on the users list.
>>>> 
>>>> Now with Adobe moving over to JS in their CS extensions, I'm going to
>>>> be
>>>> forced to move over quite a few extensions to js. (I'm hoping that will
>>>> be an opportunity for me to get more involved in FlexJSŠ)
>>>> 
>>>> One of my (many) concerns is XML processing. While I can use JSON in
>>>> some
>>>> cases, others really requires the processing to remain in XML (one
>>>> example being processing IDML data). Has anyone given any thought to
>>>> cross-compiling E4X to JS in FlexJS? WHat other options might there be
>>>> for XML processing? Maybe proxy classes which translate into E4X in
>>>> ActionScript and DOMParser in JS?
>>>> 
>>>> Harbs
>>>> 
>>>> On Sep 3, 2013, at 7:13 AM, Alex Harui wrote:
>>>> 
>>>>> FWIW, JSON should be much faster than XML so converting the other way
>>>>> might be a better idea.  And it would help future-proof the app in
>>>>> case
>>>>> you ever decide to port to JS.
>>>> 
>>> 
>> 
> 


Re: JSON to XML

Posted by Alex Harui <ah...@adobe.com>.

On 9/2/13 11:56 PM, "Harbs" <ha...@gmail.com> wrote:

>I moved over to dev because I thought it was the right place to go off on
>this tangent...
Ah, sorry, I wasn't tracking which list it was on.

E4x emulation seems really hard, so I'm not planning on taking it on for
early versions of FlexJS.  IMO, there are enough folks who are building
out JSON services that XML handling isn't a top priority.

Also, I have a hunch that doing it will be easier in the future if we can
ever drop IE8 and assume browsers that have getter/setter support.

When I did spend a few minutes looking into XML, I think I saw that
Flash's XMLDocument isn't easily done in JS either.  There might be some
new API we can have everyone write to that ports well to JS, but my
thinking is, if you have a bunch of e4x code now, re-writing that to
XMLDocument or some new procedural API would be so painful, you would just
as soon go to JSON.

We will probably support some sort of XMLDecoder/XMLEncoder like thing
that translates XML to data classes or JSON trees.  It would be great to
get some help on that if anyone is interested.  Having that and
LazyCollections should give the best performance for those who can't use
JSON backends.

But, of course, I could be wrong, and anyone who wants to take on better
XML handling in FlexJS is welcome.

-Alex




>
>On Sep 3, 2013, at 9:43 AM, Alex Harui wrote:
>
>> Are you asking me to not reply until you've copied users@?
>> 
>> On 9/2/13 11:20 PM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> I'd like to pick up on this discussion over on the users list.
>>> 
>>> Now with Adobe moving over to JS in their CS extensions, I'm going to
>>>be
>>> forced to move over quite a few extensions to js. (I'm hoping that will
>>> be an opportunity for me to get more involved in FlexJSŠ)
>>> 
>>> One of my (many) concerns is XML processing. While I can use JSON in
>>>some
>>> cases, others really requires the processing to remain in XML (one
>>> example being processing IDML data). Has anyone given any thought to
>>> cross-compiling E4X to JS in FlexJS? WHat other options might there be
>>> for XML processing? Maybe proxy classes which translate into E4X in
>>> ActionScript and DOMParser in JS?
>>> 
>>> Harbs
>>> 
>>> On Sep 3, 2013, at 7:13 AM, Alex Harui wrote:
>>> 
>>>> FWIW, JSON should be much faster than XML so converting the other way
>>>> might be a better idea.  And it would help future-proof the app in
>>>>case
>>>> you ever decide to port to JS.
>>> 
>> 
>


Re: JSON to XML

Posted by Harbs <ha...@gmail.com>.
I moved over to dev because I thought it was the right place to go off on this tangent…

On Sep 3, 2013, at 9:43 AM, Alex Harui wrote:

> Are you asking me to not reply until you've copied users@?
> 
> On 9/2/13 11:20 PM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I'd like to pick up on this discussion over on the users list.
>> 
>> Now with Adobe moving over to JS in their CS extensions, I'm going to be
>> forced to move over quite a few extensions to js. (I'm hoping that will
>> be an opportunity for me to get more involved in FlexJSŠ)
>> 
>> One of my (many) concerns is XML processing. While I can use JSON in some
>> cases, others really requires the processing to remain in XML (one
>> example being processing IDML data). Has anyone given any thought to
>> cross-compiling E4X to JS in FlexJS? WHat other options might there be
>> for XML processing? Maybe proxy classes which translate into E4X in
>> ActionScript and DOMParser in JS?
>> 
>> Harbs
>> 
>> On Sep 3, 2013, at 7:13 AM, Alex Harui wrote:
>> 
>>> FWIW, JSON should be much faster than XML so converting the other way
>>> might be a better idea.  And it would help future-proof the app in case
>>> you ever decide to port to JS.
>> 
> 


Re: JSON to XML

Posted by Alex Harui <ah...@adobe.com>.
Are you asking me to not reply until you've copied users@?

On 9/2/13 11:20 PM, "Harbs" <ha...@gmail.com> wrote:

>I'd like to pick up on this discussion over on the users list.
>
>Now with Adobe moving over to JS in their CS extensions, I'm going to be
>forced to move over quite a few extensions to js. (I'm hoping that will
>be an opportunity for me to get more involved in FlexJSŠ)
>
>One of my (many) concerns is XML processing. While I can use JSON in some
>cases, others really requires the processing to remain in XML (one
>example being processing IDML data). Has anyone given any thought to
>cross-compiling E4X to JS in FlexJS? WHat other options might there be
>for XML processing? Maybe proxy classes which translate into E4X in
>ActionScript and DOMParser in JS?
>
>Harbs
>
>On Sep 3, 2013, at 7:13 AM, Alex Harui wrote:
>
>> FWIW, JSON should be much faster than XML so converting the other way
>> might be a better idea.  And it would help future-proof the app in case
>> you ever decide to port to JS.
>


Re: JSON to XML

Posted by Harbs <ha...@gmail.com>.
I'd like to pick up on this discussion over on the users list.

Now with Adobe moving over to JS in their CS extensions, I'm going to be forced to move over quite a few extensions to js. (I'm hoping that will be an opportunity for me to get more involved in FlexJS…)

One of my (many) concerns is XML processing. While I can use JSON in some cases, others really requires the processing to remain in XML (one example being processing IDML data). Has anyone given any thought to cross-compiling E4X to JS in FlexJS? WHat other options might there be for XML processing? Maybe proxy classes which translate into E4X in ActionScript and DOMParser in JS?

Harbs

On Sep 3, 2013, at 7:13 AM, Alex Harui wrote:

> FWIW, JSON should be much faster than XML so converting the other way
> might be a better idea.  And it would help future-proof the app in case
> you ever decide to port to JS.


Re: JSON to XML

Posted by Alex Harui <ah...@adobe.com>.
Glad you got something working.

FWIW, JSON should be much faster than XML so converting the other way
might be a better idea.  And it would help future-proof the app in case
you ever decide to port to JS.

On 9/2/13 4:51 AM, "Scott Matheson" <sm...@intralinks.com> wrote:

>Thanks Chaps
>
>Real issue is I had read form file (air), and not converted to object
>first dum Š.
>
>For anyone else, this seems to work
>
>
>public static function getObjectToXML(obj:Object):XML
>        {
>        var qName:QName = new QName("root");
>        var xmlDocument:XMLDocument = new XMLDocument();
>        var simpleXMLEncoder:SimpleXMLEncoder = new
>SimpleXMLEncoder(xmlDocument);
>        var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName,
>xmlDocument);
>        var xml:XML = new XML(xmlDocument.toString());
>        return XML(xml.children());
>        }
>
>
>
>Seems to do the job
>
>
>
>On 9/2/13 12:44 PM, "Jeffry Houser" <je...@dot-com-it.com> wrote:
>
>>
>>  Any programming language should be able to convert JSON to XML [and
>>vice versa].  There are a few libraries for ColdFusion/CFML out there;
>>but I've never researched other languages.  I always prefer to use the
>>data in its native format if possible.  The Flash Player has some great
>>JSON classes.  Are you sure you need to convert it to XML?
>>
>>On 9/2/2013 7:14 AM, Scott Matheson wrote:
>>> Hi
>>>      We have an app based round XML, we had been giving some data in
>>>JSON. I was looking for a good tool to convert, I can see no good
>>>solution on the web
>>>
>>> Scott
>>>
>>>
>>> ________________________________
>>>
>>> Disclaimer: This electronic mail and any attachments are confidential
>>>and may be privileged. If you are not the intended recipient, please
>>>notify the sender immediately by replying to this email, and destroy all
>>>copies of this email and any attachments. Thank you.
>>>
>>
>>
>>--
>>Jeffry Houser
>>Technical Entrepreneur
>>http://www.jeffryhouser.com
>>203-379-0773
>>
>
>
>________________________________
>
>Disclaimer: This electronic mail and any attachments are confidential and
>may be privileged. If you are not the intended recipient, please notify
>the sender immediately by replying to this email, and destroy all copies
>of this email and any attachments. Thank you.


Re: JSON to XML

Posted by Scott Matheson <sm...@intralinks.com>.
Thanks Chaps

Real issue is I had read form file (air), and not converted to object
first dum Š.

For anyone else, this seems to work


public static function getObjectToXML(obj:Object):XML
        {
        var qName:QName = new QName("root");
        var xmlDocument:XMLDocument = new XMLDocument();
        var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
        var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName,
xmlDocument);
        var xml:XML = new XML(xmlDocument.toString());
        return XML(xml.children());
        }



Seems to do the job



On 9/2/13 12:44 PM, "Jeffry Houser" <je...@dot-com-it.com> wrote:

>
>  Any programming language should be able to convert JSON to XML [and
>vice versa].  There are a few libraries for ColdFusion/CFML out there;
>but I've never researched other languages.  I always prefer to use the
>data in its native format if possible.  The Flash Player has some great
>JSON classes.  Are you sure you need to convert it to XML?
>
>On 9/2/2013 7:14 AM, Scott Matheson wrote:
>> Hi
>>      We have an app based round XML, we had been giving some data in
>>JSON. I was looking for a good tool to convert, I can see no good
>>solution on the web
>>
>> Scott
>>
>>
>> ________________________________
>>
>> Disclaimer: This electronic mail and any attachments are confidential
>>and may be privileged. If you are not the intended recipient, please
>>notify the sender immediately by replying to this email, and destroy all
>>copies of this email and any attachments. Thank you.
>>
>
>
>--
>Jeffry Houser
>Technical Entrepreneur
>http://www.jeffryhouser.com
>203-379-0773
>


________________________________

Disclaimer: This electronic mail and any attachments are confidential and may be privileged. If you are not the intended recipient, please notify the sender immediately by replying to this email, and destroy all copies of this email and any attachments. Thank you.

Re: JSON to XML

Posted by Jeffry Houser <je...@dot-com-it.com>.
  Any programming language should be able to convert JSON to XML [and 
vice versa].  There are a few libraries for ColdFusion/CFML out there; 
but I've never researched other languages.  I always prefer to use the 
data in its native format if possible.  The Flash Player has some great 
JSON classes.  Are you sure you need to convert it to XML?

On 9/2/2013 7:14 AM, Scott Matheson wrote:
> Hi
>      We have an app based round XML, we had been giving some data in JSON. I was looking for a good tool to convert, I can see no good solution on the web
>
> Scott
>
>
> ________________________________
>
> Disclaimer: This electronic mail and any attachments are confidential and may be privileged. If you are not the intended recipient, please notify the sender immediately by replying to this email, and destroy all copies of this email and any attachments. Thank you.
>


-- 
Jeffry Houser
Technical Entrepreneur
http://www.jeffryhouser.com
203-379-0773


RE: JSON to XML

Posted by Mark Line <ma...@gmail.com>.
Could you not use the json support added to fp 11 and then use
describeType() on the returned object?

PS I haven't tried this

-----Original Message-----
From: Scott Matheson [mailto:smatheson@intralinks.com] 
Sent: 02 September 2013 12:15
To: users@flex.apache.org
Subject: JSON to XML

Hi
    We have an app based round XML, we had been giving some data in JSON. I
was looking for a good tool to convert, I can see no good solution on the
web

Scott


________________________________

Disclaimer: This electronic mail and any attachments are confidential and
may be privileged. If you are not the intended recipient, please notify the
sender immediately by replying to this email, and destroy all copies of this
email and any attachments. Thank you.