BKTValue.fromJson constructor
BKTValue.fromJson(
- dynamic json
Implementation
factory BKTValue.fromJson(dynamic json) {
if (json is String) {
return BKTString(json);
} else if (json is num) {
// This covers both int and double
return BKTNumber(json.toDouble());
} else if (json is bool) {
return BKTBoolean(json);
} else if (json is List) {
return BKTList(json.map((e) => BKTValue.fromJson(e)).toList());
} else if (json is Map) {
return BKTStructure(json.map(
(key, value) => MapEntry(key.toString(), BKTValue.fromJson(value))));
} else if (json == null) {
return const BKTNull();
} else {
throw FormatException("Cannot decode BKTValue: $json");
}
}