XStream
  1. XStream
  2. XSTR-405

Collections & Maps with named parts and no class attribute

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.5
    • Component/s: Core
    • Labels:
      None

      Description

      This could be considered as two or three different changes, but they are all similar and related. The goal is to exercise greater control over the generated XML in the common cases of Collection and Map types.

      Instead of having to choose between:

      <parts class="linked-list">
      <string>foo</string>
      <string>bar</string>
      </parts>

      and making the collection implicit (allowing named elements):

      <part>foo</part>
      <part>bar</part>

      I would like to have:
      <parts>
      <part>foo</part>
      <part>bar</part>
      </parts>

      And deserialize into whatever type of collection is found in the class – I don't need/want the strong type checking.

      I happen to like annotations, so I am thinking something like:

      @XStreamAliasCollection(name="parts", omitClass="true", itemFieldName="part")

      And something similar for Map types:

      @XStreamAliasMap(name="parts", omitClass="true", entryFieldName="part", keyFieldName="partno", valueFieldName="partname")

      to produce:

      <parts>
      <part>
      <partno>1</partno>
      <partname>foo</partname>
      </part>
      <part>
      <partno>2</partno>
      <partname>bar</partname>
      </part>
      </parts>

      And also something like:

      @XStreamAliasMap(name="parts", omitClass="true", entryFieldName="part", keyFieldName="partno", keyAsAttribute="true", valueImplicit="true"):

      to produce:

      <parts>
      <part partno="1">foo</part>
      <part partno="2">bar</part>
      </parts>

        Issue Links

          People

          • Assignee:
            Jörg Schaible
            Reporter:
            John Redford
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: