| 964 | /// fallback when the key is missing, the map is `null`, or the |
| 965 | /// value cannot be parsed as an integer. |
| 966 | public static int getInt(Map m, String key, int defaultValue) { |
| 967 | if (m == null) { |
| 968 | return defaultValue; |
| 969 | } |
| 970 | Object v = m.get(key); |
| 971 | if (v == null) { |
| 972 | return defaultValue; |
| 973 | } |
| 974 | if (v instanceof Number) { |
| 975 | return ((Number) v).intValue(); |
| 976 | } |
| 977 | try { |
| 978 | return Integer.parseInt(v.toString()); |
| 979 | } catch (NumberFormatException nfe) { |
| 980 | return defaultValue; |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | /// Retrieves a double field from a parsed JSON object, with a |
| 985 | /// fallback when the key is missing, the map is `null`, or the |