I have this code:
Dim list As Object
Set list = jsonParse.Item("list")
Dim groupedByProjectElement As New Dictionary
For i = 1 To 2
Set pE = list(i).Item("projectElement")
Dim projectElementsDictionary As New Dictionary
If groupedByProjectElement.Exists(pE.Item("businessKey")) Then
Set projectElementsDictionary = groupedByProjectElement(pE.Item("businessKey"))
projectElementsDictionary.Add projectElementsDictionary.count + 1, list(i)
End If
If Not groupedByProjectElement.Exists(pE.Item("businessKey")) Then
projectElementsDictionary.Add 1, list(i)
groupedByProjectElement.Add pE.Item("businessKey"), projectElementsDictionary
End If
Next i
In the second iteration I am getting the error:
This key is already associated with an element of this collection
But I am expecting that in the second iteration projectElementsDictionary should be a new Dictionary already.
What am I missing?
list looks something like this:
"list": [
{
"projectElement": {
"businessKey": "123",
"customerUnit": {
"businessKey": "123",
"links": [],
"shortDescription": "123",
"text": "123",
"version": null
}
}
}
]