toJson method

Map<String, Object?> toJson()

The JSON of wayfinder search --output=json in project mode.

Implementation

Map<String, Object?> toJson() => {
  'bundles': [for (final bundle in bundles) bundle.toJson()],
  'matches': [
    for (final match in matches)
      {
        'bundle': match.bundle.name,
        'bundlePath': match.bundle.path,
        'chunk': match.chunk.toMap(),
        'similarity': match.similarity,
        if (match.sourceChanged) 'sourceChanged': true,
      },
  ],
  'context': [
    for (final entry in context)
      {
        'bundle': entry.bundle.name,
        'bundlePath': entry.bundle.path,
        'chunk': entry.chunk.toMap(),
        'similarity': entry.similarity,
        'reason': entry.reason,
        'viaPath': ?entry.viaPath,
        if (entry.sourceChanged) 'sourceChanged': true,
      },
  ],
  'notices': [for (final notice in notices) notice.text],
};