MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / getInt

Method getInt

CodenameOne/src/com/codename1/io/JSONParser.java:966–982  ·  view source on GitHub ↗
(Map m, String key, int defaultValue)

Source from the content-addressed store, hash-verified

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

Callers 5

consumeMethod · 0.95
parseNonStreamingMethod · 0.95
postResponseMethod · 0.95

Calls 4

parseIntMethod · 0.95
toStringMethod · 0.95
getMethod · 0.65
intValueMethod · 0.65