parseJson function

Mapping parseJson(
  1. Map map, {
  2. Map<String, Map>? otherMaps,
  3. Object? mapUrl,
})

Parses a source map.

mapUrl, which may be either a String or a Uri, indicates the URL of the source map file itself. If it's passed, any URLs in the source map will be interpreted as relative to this URL when generating spans.

Implementation

Mapping parseJson(Map map,
    {Map<String, Map>? otherMaps, /*String|Uri*/ Object? mapUrl}) {
  if (map['version'] != 3) {
    throw ArgumentError('unexpected source map version: ${map["version"]}. '
        'Only version 3 is supported.');
  }

  if (map.containsKey('sections')) {
    if (map.containsKey('mappings') ||
        map.containsKey('sources') ||
        map.containsKey('names')) {
      throw FormatException('map containing "sections" '
          'cannot contain "mappings", "sources", or "names".');
    }
    return MultiSectionMapping.fromJson(map['sections'] as List, otherMaps,
        mapUrl: mapUrl);
  }
  return SingleMapping.fromJson(map.cast<String, dynamic>(), mapUrl: mapUrl);
}