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

json_ParseString handling of new line (\n) #67

Open
timhall opened this issue Aug 11, 2017 · 3 comments
Open

json_ParseString handling of new line (\n) #67

timhall opened this issue Aug 11, 2017 · 3 comments
Labels

Comments

@timhall
Copy link
Member

timhall commented Aug 11, 2017

See VBA-tools/VBA-Web#270 #44

I believe the n case in json_ParseString should be changed to append a vbLf instead of a vbCrLf or there should be an option to override the default behavior

@bwmilby
Copy link

bwmilby commented Nov 15, 2019

I don't think the proposed solution complies with ECMA-404. The JSON spec has \n and \r as the encoding for vbLf and vbCr respectively and does not include any conversion between Unix/Mac line endings and Windows vbCrLf.

A well formed JSON from an external source should be consistent in how it treats normal line endings. So it would be faster to do a search/replace than to do it with a comparison for each line ending. These days I would think that you would either see \n or \r\n but not \n\r nor \r. If the source doesn't contain \r\n, then you could post-process strings with a replace of vbLf with vbCrLf to get normal Windows line endings. I would suggest that be a setting for something like "normalizeWindowsLineEndings" which would default to "false".

PR #44

@houghtonap
Copy link

houghtonap commented Nov 15, 2019 via email

@bwmilby
Copy link

bwmilby commented Nov 15, 2019

The bug report is for string processing. Export is handled properly. The current code will convert \n to vbCrLf when importing JSON. This results in an extra CR for something that was encoded using this library (or anything that puts \r\n into the JSON). The proposed solution is to turn a naked \r or \n into \r\n when importing a string. In my copy, I just corrected the import to us vbLf for \n.

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

No branches or pull requests

3 participants