Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gsherman/925681 to your computer and use it in GitHub Desktop.
Save gsherman/925681 to your computer and use it in GitHub Desktop.
ClearBasic function to Transpose a JavaScript Object Into a List Of Records
Function TransposeJavaScriptObjectIntoListOfRecords( jsObject As Variant, recordType As String, recordFields As List, jsObjectFields As List) As List
Dim listOfResults As New List
listOfResults.ItemType= "record"
Dim oneResultRecord As Record
Dim index As Integer
Dim numberOfResults As Integer
Dim listIndex As Integer
Dim oneResult As Object
numberOfResults = scriptControl.Run("getNumberOfResults", jsObject)
For index = 1 To numberOfResults
Set oneResultRecord = New Record
oneResultRecord.RecordType = recordType
Set oneResult = scriptControl.Run("getResultByIndex", jsObject, index)
For listIndex = 0 To recordFields.Count - 1
oneResultRecord.SetField recordFields.ItemByIndex(listIndex), getProperty(oneResult, jsObjectFields.ItemByIndex(listIndex))
Next listIndex
listOfResults.AppendItem oneResultRecord
Next index
Set TransposeJavaScriptObjectIntoListOfRecords = listOfResults
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment