git://git.nikiroo.be
/
nikiroo-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
b063fe0
)
JsonIO: fix longs
author
Niki Roo
<niki@nikiroo.be>
Thu, 14 May 2020 13:34:34 +0000
(15:34 +0200)
committer
Niki Roo
<niki@nikiroo.be>
Thu, 14 May 2020 13:34:34 +0000
(15:34 +0200)
data/JsonIO.java
patch
|
blob
|
blame
|
history
diff --git
a/data/JsonIO.java
b/data/JsonIO.java
index beff342bea00abd1d002c00a09716438a667a182..524f99a7da2de6a56c0d5ad8bc8de027efbaacdc 100644
(file)
--- a/
data/JsonIO.java
+++ b/
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);
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 (Long) o;
- }
}
return def;
}
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);
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;
return (Integer) o;
+ if (o instanceof Long) {
+ try {
+ return (int) (long) ((Long) o);
+ } catch (Exception e) {
+ }
}
}
}
}