Formatting Workflow API

Hi there,
I am writing my own API workflow endpoint. I am returning raw text (JSON) so that I can control what is returned. This is working fine. The data I am trying to return comes from 2 tables. So table A is Assets and has a field called certificates. The certificate field is a list of Certificates.

How can I loop through each certificate in the asset and output the certificate details. At the moment I have:

{
"status": "success",
"response": {
    "Asset": {
        "type": "Camera",
        "manufacturer": "Nikon",
        "model": "Nikon X1100-1D",
        "name": "Nikon Digital Camera",
        "identifier": "62121989138190128",
        "Status": 5,
        "certificates": "E29929C2-138A-44E0-3058-2A5F911740B0, 578658768fhjgvhgfy45euyfjc"
    }
}}

But what I want to show is more like this:

{
"status": "success",
"response": {
    "Asset": {
        "type": "Camera",
        "manufacturer": "Nikon",
        "model": "Nikon X1100-1D",
        "name": "Nikon Digital Camera",
        "identifier": "62121989138190128",
        "Status": 5,
        "certificates": 
            {
            "id": "E29929C2-138A-44E0-3058-2A5F911740B0"
            },
            {
            "id": "578658768fhjgvhgfy45euyfjc"
            }
    }
}}

Anyway to do this?