getInt method

int getInt(
  1. String key
)

Implementation

int getInt(String key){
  if (!containsKey(key)) {
    throw Exception("json.getInt($key). No key");
  }
  final value = this[key];
  if (value is num) {
    return value.toInt();
  }
  if (value is String) {
    return int.parse(value);
  }
  if (value is bool){
    return value ? 1 : 0;
  }
  throw Exception("could not parse $value to int");
}