Skip to content

Conversation

@fdemmer
Copy link
Contributor

@fdemmer fdemmer commented Sep 14, 2023

Pydantics' json() method forwards all unused kwargs e.g. indent to json.dumps(). However, base.extract_export_kwargs() only considers arguments for pydantic and drops others.

My usecase is having the data loaded from a Django JSONField nicely indented when shown in a form; so at least passing on indent would be useful for me.

The suggested PR allows the kwargs used to "format" the output of json.dumps(): indent, separators and sort_keys

Please let me know if I missed a way to do that without the suggested change or any other comments!

@surenkov
Copy link
Owner

Hi @fdemmer, sorry for such a long response, been 🔥 busy on my main project;
and thank you for your contribution!

I updated your PR with extra json.dump(...) kwargs which may be still reasonable for pydantic models.

@surenkov surenkov merged commit 3edc224 into surenkov:master Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants