dump method
Implementation
String dump() {
final copy = deepCopy(_root);
// `copy` only contains the categories and sub-categories at this point,
// no document data. This loop adds each document to the tree.
for (var doc in _docsData.entries) {
final docId = doc.key;
final docProperties = doc.value;
final docCopy = getSubpath(copy, docId);
for (var property in docProperties.entries) {
// In case there is a conflict between a sub-category name and document
// property, the sub-category takes precedence, meaning the returned
// json will not return that document property.
if (!docCopy.containsKey(property.key)) {
docCopy[property.key] = property.value;
}
}
}
final encoder = JsonEncoder.withIndent(' ', myEncode);
final jsonText = encoder.convert(copy);
return jsonText;
}