Value.fromJson constructor

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

Creates a Value from a decoded json entry.

Could throw a JsonMissingKeyException if attribute could not be found in the json. Throws a TypeError if the values couldn't be parsed as string or List

Implementation

factory Value.fromJson(Map<String, dynamic> json) {
  final String attribute = json.containsKey(DirectoryKeys.attribute)
      ? json[DirectoryKeys.attribute] as String
      : throw JsonMissingKeyException(
          DirectoryKeys.attribute, json.toString());
  final Value v = Value(attribute)
    ..value = json.containsKey(DirectoryKeys.value)
        ? _createValueList(json[DirectoryKeys.value] as List<dynamic>)
        : null;
  return v;
}