I have API calls returning results stored as a CustomObject which in turn each make another call to return one or more related results using a nested foreach loop. The results are stored in binary files and that works fine. I am trying to create a nested JSON file for the metadata.
Source: ParentResult1 properties
- Name
- TotalSize
- FileCount
- Files
Sub Result of Files
- FileName
- Checksum
Ideally I want to create a json that looks like this:
[{ "Name": "Value1", "TotalSize": 15, "FileCount": 2, "Files": [{"FileName": "File1", "Checksum": "abc"},{"FileName": "File2", "Checksum": "abc"}]},{ "Name": "Value2", "TotalSize": 15, "FileCount": 2, "Files": [{"FileName": "File3", "Checksum": "abc"},{"FileName": "File4", "Checksum": "abc"}]}]
The part I'm struggling with is the nested foreach loop that gets the file information and updates the nested "files" property array with the new value(s).