Encodes the Document into a JSON structure.
Map<String, Object> toJson() { return { 'document': root.toJson(), }; }