toJson method

Map<String, Object?> toJson({
  1. bool exportFormat = false,
})

The writes as a JSON map from path strings to values (export form when exportFormat).

Keys are Path.toString() (/a/b, / for the root); CompoundWrite.fromValue reads them back.

Implementation

Map<String, Object?> toJson({bool exportFormat = false}) {
  final Map<String, Object?> writes = <String, Object?>{};
  writeTree.forEach((Path path, Node value) {
    writes[path.toString()] = value.toJson(exportFormat: exportFormat);
  });
  return writes;
}