Skip to content

Commit c25b458

Browse files
authored
Update new line handling
Addresses VBA-tools#41. Fix as per discussion in VBA-tools/VBA-Web#270
1 parent b6108e8 commit c25b458

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

JsonConverter.bas

+14-4
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,21 @@ Private Function json_ParseString(json_String As String, ByRef json_Index As Lon
557557
json_BufferAppend json_buffer, vbFormFeed, json_BufferPosition, json_BufferLength
558558
json_Index = json_Index + 1
559559
Case "n"
560-
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
561-
json_Index = json_Index + 1
560+
If VBA.Mid$(json_String, json_Index+1, 2) == "\r" Then
561+
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
562+
json_Index = json_Index + 3
563+
Else
564+
json_BufferAppend json_buffer, vbLf, json_BufferPosition, json_BufferLength
565+
json_Index = json_Index + 1
566+
End If
562567
Case "r"
563-
json_BufferAppend json_buffer, vbCr, json_BufferPosition, json_BufferLength
564-
json_Index = json_Index + 1
568+
If VBA.Mid$(json_String, json_Index+1, 2) == "\n" Then
569+
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
570+
json_Index = json_Index + 3
571+
Else
572+
json_BufferAppend json_buffer, vbCr, json_BufferPosition, json_BufferLength
573+
json_Index = json_Index + 1
574+
End If
565575
Case "t"
566576
json_BufferAppend json_buffer, vbTab, json_BufferPosition, json_BufferLength
567577
json_Index = json_Index + 1

0 commit comments

Comments
 (0)