Skip to content

Commit b00c968

Browse files
authored
Update new line handling
Resolves VBA-tools#270 and VBA-tools/VBA-JSON#41. See VBA-tools/VBA-JSON#44 for matching fix to VBA-JSON.
1 parent f80e870 commit b00c968

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/WebHelpers.bas

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,11 +2374,21 @@ Private Function json_ParseString(json_String As String, ByRef json_Index As Lon
23742374
json_BufferAppend json_buffer, vbFormFeed, json_BufferPosition, json_BufferLength
23752375
json_Index = json_Index + 1
23762376
Case "n"
2377-
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
2378-
json_Index = json_Index + 1
2377+
If VBA.Mid$(json_String, json_Index+1, 2) == "\r" Then
2378+
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
2379+
json_Index = json_Index + 3
2380+
Else
2381+
json_BufferAppend json_buffer, vbLf, json_BufferPosition, json_BufferLength
2382+
json_Index = json_Index + 1
2383+
End If
23792384
Case "r"
2380-
json_BufferAppend json_buffer, vbCr, json_BufferPosition, json_BufferLength
2381-
json_Index = json_Index + 1
2385+
If VBA.Mid$(json_String, json_Index+1, 2) == "\n" Then
2386+
json_BufferAppend json_buffer, vbCrLf, json_BufferPosition, json_BufferLength
2387+
json_Index = json_Index + 3
2388+
Else
2389+
json_BufferAppend json_buffer, vbCr, json_BufferPosition, json_BufferLength
2390+
json_Index = json_Index + 1
2391+
End If
23822392
Case "t"
23832393
json_BufferAppend json_buffer, vbTab, json_BufferPosition, json_BufferLength
23842394
json_Index = json_Index + 1

0 commit comments

Comments
 (0)