7

The call on the api returns this json:

[
{
    "RESULT": {
        "TYPES": [
            "bigint",
            "varchar",
            "varchar",
            "varchar",
            "varchar",
            "varchar",
            "date",
            "varchar",
            "int",
            "int",
            "varchar"
        ],
        "HEADER": [
            "kvk",
            "bedrijfsnaam",
            "adres",
            "postcode",
            "plaats",
            "type",
            "anbi",
            "status",
            "kvks",
            "sub",
            "website"
        ],
        "ROWS": [
            [
                "273121520000",
                "Kinkrsoftware", <-- this is the value i want
                "Oude Trambaan 7",
                "2265CA",
                "Leidschendam",
                "Hoofdvestiging",
                null,
                null,
                "27312152",
                "0",
                null
            ]
        ]
    }
}
]

I can't change the api code.

I am using Angular and I can't see to get access to the values.

This is my controller:

  .controller('MainCtrl', function($scope, $http, $log, kvkInfo) {

  kvkInfo.success(function(status, data) { 

        $scope.name = status;
    $scope.bedrijf = data;
    $scope.status = status;
      });


});

I have tried

data.RESULT.ROW, data.RESULT.ROW[1], data.RESULT[0].ROW, data.RESULT[0].ROW[1], data.ROW[1]

How can i get this element?

2 Answers 2

26
+50

What you get starts with [, so it's an array. So you need data[0].

The first element of this array (data[0]) is an object (it starts with {) which has a RESULT attribute. So you can use data[0].RESULT.

The value of the RESULT attribute is another object which has a ROWS attribute (Note the final S). So you can use data[0].RESULT.ROWS.

The value of ROWS is an array, containing another array, so you need data[0].RESULT.ROWS[0][1].

Sign up to request clarification or add additional context in comments.

Comments

2

Your api result is wrapped in an array, so you have to save the first element of it to the scope instead of the whole array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.