updateJsonWithLocalPaths static method

dynamic updateJsonWithLocalPaths(
  1. dynamic jsonResponse,
  2. List<String> extractKeys,
  3. Map<String, String> urlToLocalPathMap
)

Updates the JSON incrementally with local paths. For every URL found matching extractKeys, it adds a new property: <key>_local_path.

Implementation

static dynamic updateJsonWithLocalPaths(
  dynamic jsonResponse,
  List<String> extractKeys,
  Map<String, String> urlToLocalPathMap,
) {
  if (jsonResponse is Map) {
    return _updateMap(Map<String, dynamic>.from(jsonResponse), extractKeys, urlToLocalPathMap);
  } else if (jsonResponse is List) {
    return jsonResponse
        .map((item) => updateJsonWithLocalPaths(item, extractKeys, urlToLocalPathMap))
        .toList();
  }
  return jsonResponse;
}