PricedCoinBase.fromJson constructor

PricedCoinBase.fromJson(
  1. Map<String, dynamic> json
)

Implementation

PricedCoinBase.fromJson(Map<String, dynamic> json) {
  for (String key in json.keys) {
    if (key != "last_updated_at") {
      data[key] = (json[key] is double)
          ? json[key]
          : (json[key] is int)
              ? (json[key] as int).toDouble()
              : (json[key] is String)
                  ? double.tryParse(json[key]) ?? -3
                  : -3;

      /// -3 : could not parse value
    } else {
      lastUpdatedAtTimeStamp =
          DateTime.fromMillisecondsSinceEpoch(json["last_updated_at"]);
    }
  }
}