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

Small question #1094

Closed
martinnnnnn opened this issue May 17, 2018 · 4 comments
Closed

Small question #1094

martinnnnnn opened this issue May 17, 2018 · 4 comments

Comments

@martinnnnnn
Copy link

Hi,
Thanks for the library, it's really easy to setup and use :) I only have one small question :
Is it possible to set pretty print when printing a json object without setting it for arrays in the object ? I end up with
"obj1": {
"key1": "value1",
"key2": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
]
},
(there should be tabs but I couldn't get the code insertion to do what I want ^^')
which doesn't look very good.. Any way I can set the array to print in 1 line ? I could probably iterate thought each objects and check when there is an array and print it differenlty but that seems like a lot of work !
Thanks :)

@nlohmann
Copy link
Owner

The pretty-printer is currently not so flexible. The set indentation is used for both objects and arrays. You can, however, set the indentation character to a tabs, see https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5adea76fedba9898d404fef8598aa663.html#a5adea76fedba9898d404fef8598aa663

@martinnnnnn
Copy link
Author

martinnnnnn commented May 17, 2018

Thanks for your quick response !
If I were to look into it and add the possibility to set different identations for objects and arrays, would you like me to create a pull request or is it a feature you don't want added to the library ?
Have a good day, thanks again for the library it's awesome :)

@nlohmann
Copy link
Owner

I would like to discuss the interface first. Right now, the dump function already has 3 parameters, and I would like to avoid a complete bloat of parameters for use cases that are very rare.

@martinnnnnn
Copy link
Author

martinnnnnn commented May 17, 2018 via email

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

No branches or pull requests

2 participants