1

this is my JSON structure:

var json = {
procedure: {
    id: "content",
    child: {

        154: {
        class: "sequence nest",
        text: "LED Ausgeben",
        id: 154
        }
    }
}    
};

For some reason prop in for (var prop in scope.child){} is only a string instead of the object scope.child.154 as you can see below at Watch Expressions.

Debugger

any ideas why? i tried specifying JSON objects with "154" but it doesn't matter. do their names have to contain characters aswell?

here is the fiddle: JSFiddle but you have to use the browsers console. to check it, press on the folder icon.

cheers!

newacct
  • 119,665
  • 29
  • 163
  • 224
philx_x
  • 1,708
  • 16
  • 23

1 Answers1

1

I changed the for loop slightly. You should have access to the object doing it this way.

for (var key in scope.child) {
  var obj = scope.child[key];
  ...
}

Fiddle

Also check out Stackover post where I got the idea from

Community
  • 1
  • 1
Ryan Gill
  • 1,728
  • 2
  • 13
  • 27
  • 1
    awesome, i changed your fiddle a little bit since i don't have to iterate over all properties and can pass the whole object in the $() function. Here is the working Fiddle if you're intrested: http://jsfiddle.net/philx_x/cgojh6t1/ – philx_x Feb 25 '15 at 12:30