Q:

json obj with array

How can i loop the contacts inside my json object using javascript?
{
"success": 1,
"contacts": [
    {
        "cName": "testing",
        "cmail": "testMail",
        "ctlf": "testPhone"
    },
    {
        "cName": "testing",
        "cmail": "testMail",
        "ctlf": "testPhone"
    }
],
"fName": "Actura",
"fAdr": "langdyssen 5, 8200 Aarhus N",
"date": "14-9-2019"
}

I've tried using the code below, but it only displayed 0 and 1 at the console
$.getJSON("./ajax/get.php", {
        type: "printer",
        placement: "firm",
        id: id
    }).done(function (data) {
        if (data.success == 1) {
            //$('table#printerInfo').append("<tr><td>Printer ID</td><td>" + data.id + "</td></tr>").append("<tr><td>M&aeligrke</td><td>" + data.brand + "</td></tr>").append("<tr><td>Model</td><td>" + data.model + "</td></tr>").append("<tr><td>Farve</td><td>" + data.color + "</td></tr>");
            $('table td#firmName').append('<span class="glyphicon glyphicon-home"></span> ' + data.fName);
            $('table td#firmAdr').append('<span class="glyphicon glyphicon-globe"></span> ' + data.fAdr);
            $('table td#firmDate').append('<span class="glyphicon glyphicon-calendar"></span> ' + data.date);

            for (var contact in data.contacts) {
                console.log(contact);
            }
            console.log(data);
            toolTip();
        }
        else {
            alert("Der er sket en fejl: " + data.error);
        }
    });

Replaced data with test data, and due to 'too much code' ill be adding some ekstra text since i cant delete the question due to answers

A:

Use code below instead:
        for (var i in data.contacts) {
            console.log(data.contacts[i]);
        }

