Merge branch 'subtree'
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 13:35:20 +0000 (15:35 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 13:35:20 +0000 (15:35 +0200)
1  2 
src/be/nikiroo/fanfix/data/JsonIO.java

index beff342bea00abd1d002c00a09716438a667a182,524f99a7da2de6a56c0d5ad8bc8de027efbaacdc..524f99a7da2de6a56c0d5ad8bc8de027efbaacdc
@@@ -287,9 -287,14 +287,14 @@@ public class JsonIO 
        static long getLong(JSONObject json, String key, long def) {
                if (json.has(key)) {
                        Object o = json.get(key);
-                       if (o instanceof Long) {
+                       if (o instanceof Byte)
+                               return (Byte) o;
+                       if (o instanceof Short)
+                               return (Short) o;
+                       if (o instanceof Integer)
+                               return (Integer) o;
+                       if (o instanceof Long)
                                return (Long) o;
-                       }
                }
  
                return def;
        static int getInt(JSONObject json, String key, int def) {
                if (json.has(key)) {
                        Object o = json.get(key);
-                       if (o instanceof Integer) {
+                       if (o instanceof Byte)
+                               return (Byte) o;
+                       if (o instanceof Short)
+                               return (Short) o;
+                       if (o instanceof Integer)
                                return (Integer) o;
+                       if (o instanceof Long) {
+                               try {
+                                       return (int) (long) ((Long) o);
+                               } catch (Exception e) {
+                               }
                        }
                }