X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fdata%2FJsonIO.java;h=524f99a7da2de6a56c0d5ad8bc8de027efbaacdc;hb=14c0debd37e7de3fa8b5acb81c234f96452ec2a2;hp=beff342bea00abd1d002c00a09716438a667a182;hpb=e14f67abf357c8db74aa230faf8922f93f59c7d6;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/data/JsonIO.java b/src/be/nikiroo/fanfix/data/JsonIO.java index beff342..524f99a 100644 --- a/src/be/nikiroo/fanfix/data/JsonIO.java +++ b/src/be/nikiroo/fanfix/data/JsonIO.java @@ -287,9 +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; @@ -309,8 +314,17 @@ public class JsonIO { 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) { + } } }