tags:

views:

18

answers:

1
    Gson gson = new Gson();

    Map<String,Object> map = new HashMap<String, Object>();
    map.put("a",1);
    map.put("b",null);

    System.out.println(gson.toJson(map));; //prints {"a":1}

how do I get it to include all entries? Thank you

+2  A: 

http://sites.google.com/site/gson/gson-user-guide#TOC-Null-Object-Support

Gson gson = new GsonBuilder().serializeNulls().create();

RTFM !

Alois Cochard
OK, I deserved that... :p
m2o
So I think you can accept then answer ... or you prefer I remove the 'RTFM' before ;-)
Alois Cochard