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 Not Proper Printing Algorithm #7

Closed
jredfox opened this issue Mar 7, 2019 · 3 comments
Closed

Pretty Print Not Proper Printing Algorithm #7

jredfox opened this issue Mar 7, 2019 · 3 comments

Comments

@jredfox
Copy link

jredfox commented Mar 7, 2019

Pretty print doesn't look right when outputted compared to test against gson https://github.com/google/gson and https://jsoneditoronline.org/

Also on windows you fail to provide the proper line mechanics making me use non native windows notepad to edit the file. \r\n is the proper format or get it dynamically from the system.

@jredfox jredfox changed the title Pretty Print Not Proper Algorithm Pretty Print Not Proper Printing Algorithm Mar 7, 2019
@RalleYTN
Copy link
Owner

I'll look into it but could you give me more info on why the output looks wrong?
Do you have an example JSON string in which these errors occur?

for the line break on windows you should use the following method:

JSONFormatter formatter = new JSONFormatter();
formatter.setUseCRLF(true); // flag that makes the formatter use \r\n instead of \n

@RalleYTN RalleYTN added the bug label Mar 13, 2019
@jredfox
Copy link
Author

jredfox commented Mar 13, 2019

just do what the steps to reproduce are then compare the same string with json editor online after formatting it to theirs it looks way different.

@RalleYTN
Copy link
Owner

Again the JSONFormatter class has methods that allow for customizing the pretty print output. In case of line break mechanics you can set it to use windows line breaks with the setUseCRLF method inside the JSONFormatter. you can also use methods like setIndent to determine the indent and setUseTabs to set wether the indent should use tabs or spaces.

I will close this issue as it really isnt an issue.

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