X Tutup
The Wayback Machine - https://web.archive.org/web/20201206191646/https://github.com/simdjson/simdjson/issues/1329
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty print for DOM #1329

Open
mmatrosov opened this issue Dec 4, 2020 · 2 comments
Open

Pretty print for DOM #1329

mmatrosov opened this issue Dec 4, 2020 · 2 comments
Milestone

Comments

@mmatrosov
Copy link
Contributor

@mmatrosov mmatrosov commented Dec 4, 2020

Is your feature request related to a problem? Please describe.
There is no way to pretty print a simdjson::dom::element to a string (or at least I did not find one). There is only a way to minify it to a string (or a stream).

Describe the solution you'd like
A function like to_pretty_string() or a configurable stream manipulator pretty or a stand-alone class PrettyPrinter. Whatever fits.

Pretty-printing json is a very common task used in various places. Basically, whenever a human needs to take a look on the stored json, it is better to display it with proper structure and indentation.

Describe alternatives you've considered
Using minified version is ok in some cases, but sometimes you really want a pretty verion. I see no other way than writing my own formatter.

** Are you willing to contribute code or documentation toward this new feature? **
Probably, but not sure. Nothing to contribute as of yet.

@lemire lemire added this to the 1.0 milestone Dec 4, 2020
@lemire
Copy link
Member

@lemire lemire commented Dec 4, 2020

This is an entirely valid issue.

@lemire
Copy link
Member

@lemire lemire commented Dec 4, 2020

Our DOM serialization code is literally generic, see
https://github.com/simdjson/simdjson/blob/master/include/simdjson/dom/serialization.h#L31

So all that is needed is to write a formatter. Currently, we only have mini_formatter. One would need to write a pretty_formatter. It is actually entirely doable in a relatively short time. I wrote the serialization code we have now with this prettifier option in mind.

I believe that it could be done by someone who is not an expert in our code base.

Contributions invited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup