talatabao / as3corelib

Automatically exported from code.google.com/p/as3corelib
0 stars 0 forks source link

JSON does not encode XML instances into anything useful #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. trace( JSON.encode( <test attr1="test" attr2="42"><child1
childAttr1="false" /></test> ) );

What is the expected output? What do you see instead?

Like Date instance (see issue #2), there is no standard XML encoding syntax
defined for JSON.  Because E4X is a core part of ECMAScript Edition 4, I
would suspect that the JSON-encoded XML would just use <> like an XML literal.

So, the above trace would produce the following JSON string:

"<test attr1=\"test\" attr2=\"42\"><child1 childAttr1=\"false\" /></test>"

Along the same lines, the following:

  var arr:Arary = new Array();
  arr.push( <test /> );
  arr.push( true );
  trace( JSON.encode( arr ) );

... should probably output:  "[<test/>,true]"

The current output is {}, which is clearly not good, no matter what the
expected output should be.

Please use labels and text to provide additional information.

There needs to be a consensus on what the expected output should be before
this is addressed.  

This could spring into a religious debate, "Why on earth would anyone want
to encode XML in JSON?  It's apples and oranges!"... but rather than get
into politics, I'd rather just agree on a universal solution / standard for
dealing with XML instances in JSON encoding.

Original issue reported on code.google.com by darron.schall on 29 Dec 2006 at 9:02

GoogleCodeExporter commented 9 years ago
Changed issue title (accidentally left it as default when I entered it).

Original comment by darron.schall on 29 Dec 2006 at 9:02

GoogleCodeExporter commented 9 years ago
I believe Firefox 2 has support for e4x. Might be useful to see how they handle 
it.

Original comment by mikechambers on 10 Jan 2007 at 4:41