InspectTree.fromJson constructor

InspectTree.fromJson(
  1. Map<String, Object?> json
)

Reads either spelling — see toJson for what compact changes and why a reader has to know both.

Implementation

factory InspectTree.fromJson(Map<String, Object?> json) {
  var root = switch (json['root']) {
    Map root => root.cast<String, Object?>(),
    _ => null,
  };
  var format = json['format'] as int?;
  if (root == null) {
    return InspectTree(entryId: json['entry'] as String?, format: format);
  }
  return InspectTree(
    entryId: json['entry'] as String?,
    format: format,
    root: json['compact'] == true
        ? _readCompact(root, '', [
            for (var file in json['files'] as List? ?? const []) '$file',
          ])
        : InspectNode.fromJson(root),
  );
}