Project

General

Profile

Actions

Defect #7132

closed

do not include empty nodes to XML response when no value is set

Added by Alex Last over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
High
Category:
REST API
Target version:
-
Start date:
2010-12-18
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
Affected version:

Description

I'm trying to parse the "issues.xml" response from Redmine REST API using Java and Castor XML library.
this is the text I get from the server (I skipped some not related items):

<issue>
    <id>210</id>
    <project name="ace" id="9579" />
    <subject>testGetIssues: Sat Dec 18 11:47:13 PST 2010</subject>
    <description></description>
    <start_date>2010-12-18</start_date>
    <due_date></due_date>
    <done_ratio>0</done_ratio>
    <estimated_hours></estimated_hours> <---- can this be REMOVED from the response?
</issue>

as you can see, "estimated_hours" and some other xml nodes are included even though they don't have any values.
unfortunately, Castor XML parsing library believes that if the node is present, then its value must be initialized, which means the Java object will get

  Float estimatedHours = 0.0

value instead of NULL (as it should!).

so I'm wondering if it's possible to not add empty nodes in the xml response in REST API?
this seems like an easy and useful thing to do, so I'm setting the priority to High.

I believe it should be done in a generic way so that other empty nodes are omitted in the xml response as well (like "due_date" in my example above) - although my main concern at this moment is "estimated_hours".

Actions

Also available in: Atom PDF