question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Control formatting with `dump` / `dumps`

See original GitHub issue

Is there any way to control JSON5 aspects of formatting when using dump / dumps? For example, whether to quote key names of objects, or whether to include trailing commas.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dprankecommented, Oct 6, 2021

Yes, it should quote keys with spaces properly. I could imagine a single/double quote flag to be useful, though.

1reaction
dprankecommented, Oct 6, 2021

Yes, both of those things are supported, in fact 😃.

Unfortunately at the moment I don’t have this lifted into obvious documentation (which I should fix), but if you look at the docstring for dumps:

https://github.com/dpranke/pyjson5/blob/main/json5/lib.py#L154

json5.dumps supports all of the args of json.dumps, plus three additional ones: allow_duplicate_keys, quote_keys, and trailing_commas. If you have other formatting options you’d like to see, I’m open to hearing about them 😃.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formatting system dumps - IBM
Formatting system dumps. You can process system dumps from the dump data set by invoking the interactive problem control system (IPCS).
Read more >
JSON dumps custom formatting - python - Stack Overflow
I have used the example provided by Tim Ludwinski and adapted it to my preference: class CompactJSONEncoder(json.JSONEncoder): """A JSON Encoder that puts ...
Read more >
Documentation: 15: 26.1. SQL Dump - PostgreSQL
You can control the degree of parallelism with the -j parameter. Parallel dumps are only supported for the "directory" archive format. pg_dump -j...
Read more >
OpenVMS DCL Dictionary
By default, the DUMP command formats the output both in ASCII characters and in hexadecimal longwords. You can specify another format for the...
Read more >
dump command - LAMMPS documentation
The atom, custom, grid, and local styles create files in a simple LAMMPS-specific text format that is self-explanatory when viewing a dump file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found