AWS textract API response to Json file

Hi Experts

I am using AWS API for document analysis as per official uipath documentation.
Get_Document_analysis
As per doc , API returns pageDetails type argument is uipath.amazon.textract.client.model.pageDetailCollection

I wonder how can I direct o/p to json file and same time do “write_line” also .get_doc_analysis

I am not even able to iterate over this uipath.amazon.textract.client.model.pageDetailCollection data type.
Error I get when I do for each is : option strict on disallows implicit conversions from uipath.amazon.textract.client.model.pageDetailCollection to ‘system.collections.ienumerable’