Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 512 by
chanda...@gmail.com: Exclude empty array in Gson
serialization
http://code.google.com/p/google-gson/issues/detail?id=512
What steps will reproduce the problem?
1. In Java class, define an attribute as List
private List<Score> Scores = new ArrayList<Score>();
2. If Score (ArrayList) is not populated or empty, while generating JSON
file, an empty array is getting generated
],
"scores": []
},
What is the expected output? What do you see instead?
Option 1 - If a collection or an array is empty, it should not generate an
empty array.
Example - com.google.gson.internal.bind.CollectionTypeAdapterFactory.write()
existing code - if (collection == null) {
expected - if (collection == null || collection.size() < 1) {
Option 2 - configuration property to enable/disable adding empty array,
similar to Jackon SerializationFeature.WRITE_EMPTY_JSON_ARRAYS
(
http://wiki.fasterxml.com/JacksonFeaturesSerialization)
What version of the product are you using? On what operating system?
version 2.2.3
operating system - Mac OSX 10.8.3
Please provide any additional information below.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings