Good morning, despite reading of useful topics (VBA-JSON Create nested objects), i dont know how to build a JSON with lot os sub elements like this :
[{
"data": {
"type": "objects",
"attributes": {
"seq": 0,
"1": {
"value": "mom",
}
},
"relationships": {
"objectType": {
"data": {
"type": "objectType"
}
},
"parent": {
"data": {
"id": "14132",
}
}
}
}
},
{
"data": {
"type": "objects",
"attributes": {
"seq": 0,
"1": {
"value": "dad",
}
},
"relationships": {
"objectType": {
"data": {
"type": "objectType"
}
},
"parent": {
"data": {
"id": "45823",
}
}
}
}
}]
This my current code :
Dim rot As Collection
Dim rp As Collection
Dim d As Dictionary
Dim e As Dictionary
Dim f As Dictionary
Dim g As Dictionary
Dim h As Dictionary
Dim json As String
Set rot = New Collection
Set rp = New Collection
Set d = New Dictionary
Set e = New Dictionary
Set f = New Dictionary
Set g = New Dictionary
Set h = New Dictionary
d.Add "type", "objectType"
d.Add "id", "76"
e.Add "data", d
rot.Add e
f.Add "objectType", rot
Set d = New Dictionary
Set e = New Dictionary
d.Add "id", "14332"
e.Add "data", d
rp.Add e
f.Add "parent", rp
g.Add "relationships", f
json = JsonConverter.ConvertToJson(ByVal g)
But output is not correct i want :
{"relationships":{"objectType":[{"data":{"type":"objectType","id":"76"}}],"parent":[{"data":{"id":"14332"}}]}}