compute output in JSON format.

def format(file_metrics, build_metrics):
    """compute output in JSON format."""
    metrics = {'files': file_metrics}
    if build_metrics:
        metrics['build'] = build_metrics
    body = json.dumps(metrics, sort_keys=True, indent=4) + '\n'
    return body