Skip to content

json_ParseString handling of new line (\n) #67

Description

@timhall

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

Activity

  1. bwmilby commented on Nov 15, 2019

    @bwmilby

    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

  2. houghtonap commented on Nov 15, 2019

    @houghtonap
  3. bwmilby commented on Nov 15, 2019

    @bwmilby

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions