How to pretty print data class?
See original GitHub issueI have some code like this:
data class MyClass(val list: List<String>, i: Int)
val obj = MyClass(listOf(), 1)
Klaxon().toJsonString(obj)
However, this results in a string without any whitespace or formatting. Is there another call that applies formatting to the output string? The readme recommends JsonObject.toJsonString()
, but I cant find any way to turn my object into a JsonObject with klaxon.
What is the correct way to do this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Pretty-print dataclasses prettier - python - Stack Overflow
Basically I'm looking for a way to customize the default dataclasses string representation routine or for a pretty-printer that understands data ...
Read more >pprint — Data pretty printer — Python 3.11.1 documentation
The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the...
Read more >Kotlin: pretty print data classes - DEV Community
The only little trick worth mentioning is that I first call toString() on the data class, and extract all properties present in the...
Read more >Prettify Your Data Structures With Pretty Print in Python
The pprint module in Python is a utility module that you can use to print data structures in a readable, pretty way. It's...
Read more >Pretty printing dataclasses · Discussion #891 · Textualize/rich
Is there an automatic-ish way to get black-like spacing for the output of a data class, without going member by member with something...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@camdenorrb +1
It would be nice to have
Why do you first have to convert it to a String… And then parse it…