jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-460

JettisonMappedXmlDriver doesn't work for collection object

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.2.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • JDK version and platform:
    1.6u3 for linux

Description

//the following test will always failed
public void testArrayListOrder() { XStream xs = new XStream(new JettisonMappedXmlDriver()); ArrayList list1 = new ArrayList(); list1.clear(); list1.add(12); list1.add("string"); list1.add(13); String json = xs.toXML(list1); ArrayList list2 = (ArrayList)xs.fromXML(json); assertEquals(json,xs.toXML(list2)); }

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Wang Qi added a comment - 19/Dec/07 12:13 AM

actually, i tried with list, vector and array. both of them failed. that's why i issue this bug:
JettisonMappedXmlDriver doesn't work for collection object.

Show
Wang Qi added a comment - 19/Dec/07 12:13 AM actually, i tried with list, vector and array. both of them failed. that's why i issue this bug: JettisonMappedXmlDriver doesn't work for collection object.
Hide
Permalink
Joerg Schaible added a comment - 19/Dec/07 2:00 AM

Unfortunately this is another issue with Jettison itself ... :-/

Show
Joerg Schaible added a comment - 19/Dec/07 2:00 AM Unfortunately this is another issue with Jettison itself ... :-/
Hide
Permalink
Joerg Schaible added a comment - 23/Jan/08 6:27 PM

Hi,

after some investigation, I have to state that the problem is related to the way Jettison maps the XML into JSON arrays. See Jettison's user guide and you'll know that Jettison will only put XML elements into an array if they are at the same level and have the same name. In your case it will map the collection into an object containing an array of ints and a single string. And it will also deserialize this. It is just that the original sequence of the elements is no longer kept. You may use the JsonHierarchicalStreamDriver to generate the JSON, but recognize the different JSON representation. Here the renderer did know exactly what types it dealt with and how they have to be written into proper JSON. However, the resulting JSON string does no longer contain enough information to recreate the original objects. Main problem is, that you cannot express all necessary data in JSON to guarantee a 1:1 deserialization into arbitrary Java objects.

  • Jörg
Show
Joerg Schaible added a comment - 23/Jan/08 6:27 PM Hi, after some investigation, I have to state that the problem is related to the way Jettison maps the XML into JSON arrays. See Jettison's user guide and you'll know that Jettison will only put XML elements into an array if they are at the same level and have the same name. In your case it will map the collection into an object containing an array of ints and a single string. And it will also deserialize this. It is just that the original sequence of the elements is no longer kept. You may use the JsonHierarchicalStreamDriver to generate the JSON, but recognize the different JSON representation. Here the renderer did know exactly what types it dealt with and how they have to be written into proper JSON. However, the resulting JSON string does no longer contain enough information to recreate the original objects. Main problem is, that you cannot express all necessary data in JSON to guarantee a 1:1 deserialization into arbitrary Java objects.
  • Jörg
Hide
Permalink
Joerg Schaible added a comment - 25/Feb/08 4:53 PM

Closed after no further comment has been given.

Show
Joerg Schaible added a comment - 25/Feb/08 4:53 PM Closed after no further comment has been given.

People

  • Assignee:
    Joerg Schaible
    Reporter:
    Wang Qi
Vote (0)
Watch (0)

Dates

  • Created:
    19/Dec/07 12:08 AM
    Updated:
    25/Feb/08 4:53 PM
    Resolved:
    23/Jan/08 6:27 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.