Private Sub testSr()
Dim sFix As String, cr As cRest, outer As String, job As cJobject, joa As cJobject, _
joe As cJobject, joc As cJobject, r As Range
' simulate some results
outer = "stepResults"
sFix = "{'data':[ " & _
"{'a':'first','stepResults':[{'sa':'a1' ,'sb' :'b1' }, { 'sa':'a2' ,'sb' :'b2' }]} " & _
",{'a':'second','stepResults':[{'sa':'c1' ,'sb' :'d1' }, { 'sa':'c2' ,'sb' :'d2' }]} " & _
"] }"
' do a fake query and dont populate- replace this with the real query
With restQuery("sr", , , , "dummyurl", "data", , False, , , True, sFix)
' so now we have the data, first step, clear any existing data
With .dset
If Not .where Is Nothing Then .where.ClearContents
Set r = firstCell(.headingRow.where)
End With
'next just go through each row
For Each job In .datajObject.children
Set joe = job.childExists(outer)
' must always have one I guess
Debug.Assert Not joe Is Nothing
' now make a row for each item in the outer join
For Each joc In joe.children
' assuming that every child of the inner array has been set up as a column heading.
' and that outer is an array
Debug.Assert joc.isArrayMember
Set r = r.Offset(1)
' duplicate the other children
For Each joa In job.children
If joa.key <> outer Then
If Not .dset.headingRow.exists(joa.key) Is Nothing Then
r.Offset(, .dset.column(joa.key).column - 1).value = joa.value
End If
End If
Next joa
For Each joa In joc.children
If Not .dset.headingRow.exists(joa.key) Is Nothing Then
r.Offset(, .dset.column(joa.key).column - 1).value = joa.value
End If
Next joa
Next joc
Next job
' and release any memory
.tearDown
End With
End Sub