Skip to content

Implement/document a way how to pass extra configuration to json.dump() #526

@honzajavorek

Description

@honzajavorek

There is useful configuration to json.dump() which I'd like to pass through await crawler.export_data("export.json"), but I see no way to do that:

  • ensure_ascii - as someone living in a country using extended latin, setting this to False prevents Python to encode half of the characters as weird mess
  • indent - allows me to read the output as a mere human
  • sort_keys - may be useful for git scraping, not sure

The only workaround I can think of right now is something convoluted like:

from pathlib import Path

path = Path("export.json")
await crawler.export_data(path)
path.write_text(json.dumps(json.loads(path.read_text()), ensure_ascii=False, indent=2))

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions