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

Feature request: expose indent_string as an optional arg to prettify() #448

Open
mmuurr opened this issue Feb 22, 2025 · 3 comments
Open

Comments

@mmuurr
Copy link

mmuurr commented Feb 22, 2025

I'd like to be able to pass \t as the indent_string to prettify() (as downstream files are diffed and the upstream -- which I can't control -- uses tabs).

Could we add indent_string as an optional argument to prettify() that:

  • when present, ignores indent and
  • is passed along to reformat() (perhaps after valdiating that indent_string is indeed a string)?

It's obviously somewhat easy to just use jsonlite:::reformat() instead, but I'd much rather stick with the public API, if possible.

I'm happy to gin-up this relatively simple PR if likely to be approved.

@jeroen
Copy link
Owner

jeroen commented Feb 22, 2025

Hmm maybe it is easier to overload the indent parameter than introduce a new one.

@mmuurr
Copy link
Author

mmuurr commented Feb 22, 2025

Oh, yeah ... that's a much better API/arg usage (than my indent_string idea).

@jeroen
Copy link
Owner

jeroen commented Feb 22, 2025

I think the reason why we decided it was unsafe to expose, is that yajl crashes for some values:

jsonlite:::reformat('{"x":123}', TRUE, 'x')

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

No branches or pull requests

2 participants