diff options
Diffstat (limited to 'src/net/pacien/util/CleanJSONObject.java')
-rw-r--r-- | src/net/pacien/util/CleanJSONObject.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/net/pacien/util/CleanJSONObject.java b/src/net/pacien/util/CleanJSONObject.java new file mode 100644 index 0000000..0982ca8 --- /dev/null +++ b/src/net/pacien/util/CleanJSONObject.java | |||
@@ -0,0 +1,48 @@ | |||
1 | package net.pacien.util; | ||
2 | |||
3 | import java.util.Collection; | ||
4 | import java.util.Map; | ||
5 | |||
6 | import org.json.simple.JSONObject; | ||
7 | |||
8 | public class CleanJSONObject extends JSONObject { | ||
9 | |||
10 | /** | ||
11 | * | ||
12 | */ | ||
13 | private static final long serialVersionUID = 6700060746446264070L; | ||
14 | |||
15 | public CleanJSONObject() { | ||
16 | super(); | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public Object put(final String key, final Object value) { | ||
21 | if (value == null) { | ||
22 | return null; | ||
23 | } | ||
24 | return super.put(key, value); | ||
25 | } | ||
26 | |||
27 | public Object put(final String key, final Map<?, ?> map) { | ||
28 | if (map.isEmpty()) { | ||
29 | return null; | ||
30 | } | ||
31 | return super.put(key, map); | ||
32 | } | ||
33 | |||
34 | public Object put(final String key, final Collection<?> collection) { | ||
35 | if (collection.isEmpty()) { | ||
36 | return null; | ||
37 | } | ||
38 | return super.put(key, collection); | ||
39 | } | ||
40 | |||
41 | public Object put(final String key, final Object[] array) { | ||
42 | if (array.length == 0) { | ||
43 | return null; | ||
44 | } | ||
45 | return super.put(key, array); | ||
46 | } | ||
47 | |||
48 | } | ||