← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6755: Writing empty string instead of null in report table data

 

------------------------------------------------------------
revno: 6755
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-04-26 12:56:58 +0200
message:
  Writing empty string instead of null in report table data
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonRowDataSerializer.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonRowDataSerializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonRowDataSerializer.java	2012-04-26 07:56:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonRowDataSerializer.java	2012-04-26 10:56:58 +0000
@@ -42,6 +42,7 @@
 {
     private static final String ROW_NAME = "row";
     private static final String FIELD_NAME = "field";
+    private static final String EMPTY = "";
     
     @Override
     public void serialize( List<List<Object>> values, JsonGenerator jgen, SerializerProvider provider ) throws IOException
@@ -61,7 +62,9 @@
 
             for ( Object object : value )
             {
-                jgen.writeStringField( FIELD_NAME, "" + object );
+                object = object == null ? EMPTY : object;
+                    
+                jgen.writeStringField( FIELD_NAME, String.valueOf( object ) );
             }
 
             jgen.writeEndObject();