1
1
Attribute VB_Name = "RestHelpers"
2
2
''
3
- ' RestHelpers v2.0.0
3
+ ' RestHelpers v2.0.1
4
4
' (c) Tim Hall - https://github.com/timhall/Excel-REST
5
5
'
6
6
' Common helpers RestClient
@@ -398,6 +398,7 @@ End Function
398
398
' - Updated json_parseNumber to reduce chance of overflow
399
399
' - Swapped Mid for Mid$
400
400
' - Handle colon in object key
401
+ ' - Handle duplicate keys in object parsing
401
402
' - Change methods to Private and prefix with json_
402
403
'
403
404
' ======================================================================================== '
@@ -442,8 +443,9 @@ Private Function json_parseObject(ByRef str As String, ByRef index As Long) As O
442
443
If Mid$(str, index, 1 ) <> "{" Then Err.Raise vbObjectError + INVALID_OBJECT, Description:="char " & index & " : " & Mid$(str, index)
443
444
index = index + 1
444
445
445
- Do
446
+ Dim Key As String
446
447
448
+ Do
447
449
Call json_skipChar (str, index)
448
450
If "}" = Mid$(str, index, 1 ) Then
449
451
index = index + 1
@@ -453,11 +455,12 @@ Private Function json_parseObject(ByRef str As String, ByRef index As Long) As O
453
455
Call json_skipChar (str, index)
454
456
End If
455
457
456
- Dim Key As String
457
-
458
- ' add key/value pair
459
- json_parseObject.Add Key:=json_parseKey(str, index), Item:=json_parseValue(str, index)
460
-
458
+ Key = json_parseKey(str, index)
459
+ If Not json_parseObject.Exists(Key) Then
460
+ json_parseObject.Add Key, json_parseValue(str, index)
461
+ Else
462
+ json_parseObject.Item(Key) = json_parseValue(str, index)
463
+ End If
461
464
Loop
462
465
463
466
End Function
0 commit comments