XStream
  1. XStream
  2. XSTR-76

Don't serialize fields with default values

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      In order to keep the XML small, it would be nice to ignore fields for which the default values are not changed, similar to the way it is done in the XMLEncoder:

      Eg:
      public class MyClass {

      private int m_value = 2;

      public int getValue()

      { return m_value; }

      public void setValue(int value)

      { m_value = value; }

      public MyClass() {
      }
      }

      Serializing a new instance of this class, without changing the value gives following output:

      //XStream
      <com.alcatel.ni.commands.core.MyClass>
      <m_value>2</m_value>
      </com.alcatel.ni.commands.core.MyClass>

      //XMLEncoder:
      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.2" class="java.beans.XMLDecoder">
      <object class="com.alcatel.ni.commands.core.MyClass"/>
      </java>

        Issue Links

          People

          • Assignee:
            Unassigned
            Reporter:
            gui
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: