i have a JSON that i'm looping through to extract data. right now it's written like this...

var i = 1;
while (eval("output.network[0].port" + i + "[0]")) {
    // stuff
the loop works perfectly and ends when it comes to a value that's null, but it reports an error saying that "output.network[0].port3[0] has no properties".

there's only 2, so that makes sense, but i don't want an error to occur.