var data = JSON.parse(value),
    result = [];

if (data.length === 0) {
    return '[]'
};
data.forEach(function (service) {

    result.push({
        '{#TYPE}': 'aggregated_status',
        '{#SERVICE_NAME}': service.name,
        '{#SERVICE_ID}': service.id,
        '{#SERVICE_NAMESPACE}': service.namespace
    });

    if (service['checks'] !== 0) {
        service['checks'].forEach(function (check) {
            result.push({
                '{#TYPE}': 'service_check',
                '{#SERVICE_NAME}': service.name,
                '{#SERVICE_ID}': service.id,
                '{#SERVICE_NAMESPACE}': service.namespace,
                '{#SERVICE_CHECK_ID}': check["CheckID"],
                '{#SERVICE_CHECK_NAME}': check["Name"]
            });
        });
    }

});

return JSON.stringify(result)