You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class GsonNullExample {
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put("key", null);
Gson gson = new GsonBuilder().serializeNulls().create();
System.out.println(gson.toJson(map));
}
}
What is the expected output? What do you see instead?
The output is:
{"key":null}
I would like the option to set a custom value for null, e.g. "" :
{"key":""}
Perhaps serializeNulls() could be overloaded to serializeNulls(String
nullStringValue), to allow custom String instead of the word "null".
What version of the product are you using? On what operating system?
gson 2.1 on Mac OSx using Eclipse.
Please provide any additional information below.
Original issue reported on code.google.com by a...@matan.name on 28 Feb 2012 at 5:48
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
a...@matan.name
on 28 Feb 2012 at 5:48The text was updated successfully, but these errors were encountered: