Link.fromJson constructor

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

Creates a Link from a decoded json entry.

Could throw a JsonMissingKeyException if association could not be found in the json. Throws a TypeError if the target couldn't be parsed correctly.

Implementation

factory Link.fromJson(Map<String, dynamic> json) {
  final String association = json.containsKey(DirectoryKeys.association)
      ? json[DirectoryKeys.association] as String
      : throw JsonMissingKeyException(
          DirectoryKeys.association, json.toString());
  final Link l = Link(association)
    ..target = json.containsKey(DirectoryKeys.target)
        ? DirObject.fromJson(
            json[DirectoryKeys.target] as Map<String, dynamic>)
        : null;
  return l;
}