fromJson static method

ToolsConfig fromJson(
  1. Object? json
)

Restores a config from toJson's envelope. Strict like fromYaml.

Implementation

static ToolsConfig fromJson(Object? json) {
  if (json == null) return const ToolsConfig();
  if (json is! Map) {
    throw ConfigException(
      'tools envelope must be a map, got: ${json.runtimeType}',
    );
  }
  final toolsNode = json['tools'];
  if (toolsNode == null) return const ToolsConfig();
  if (toolsNode is! Map) {
    throw ConfigException(
      '"tools" must be a map, got: ${toolsNode.runtimeType}',
    );
  }
  return ToolsConfig(tools: _parseToolsEntries(toolsNode));
}