Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

Haw can i parse this json?

{"A":{"A":{"1":{"1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7"},"2":{"1":"8","2":"9","3":"10","4":"11","5":"12","6":"13","7":"14"},"3":{"1":"15","2":"16","3":"17","4":"18","5":"19","6":"20","7":"21"}},"B":{"1":{"1":"22","2":"23","3":"24","4":"25","5":"26","6":"27","7":"28"},"2":{"1":"29","2":"30","3":"31","4":"32","5":"33","6":"34","7":"35"},"3":{"1":"36","2":"37","3":"38","4":"39","5":"40","6":"41","7":"42"}}}}

I try this, but... does not work, and lot of more things but i'm very new on this and i can't resolve myself

for (var i = 0; i < datos.A.length; i++) {
    items.push( "<div class='rackCod'>" + val[0] + "</div>" );
}
share|improve this question
    
Object Literals don't have a length property. Use for(var i in datos.A){}. – PHPglue Mar 6 at 0:21
    
It's not an array, and it's not JSON, it's a JavaScript object. What do you mean by "parsing" it? It's already an object and does not need parsing. Do you mean trying to find values inside the nested object? – torazaburo Mar 6 at 6:00
    
Thanks por helping me I'm trying to draw something like this canalverdepy.com/captura.png – arasaIT Mar 6 at 11:53
    
I found the way for (var i in datos) { items.push( "<div class='rackCod'>" + i); for (var j in datos[i]) { items.push( "<div class='rackCod'>" + j); for (var k in datos[i][j]) { items.push( "<div class='rackposPG'>" + datos[i][j][k] + "</div>"); } items.push( "</div><br><br><br>"); } items.push( "</div>"); } Thanks for the answers, it's help me alot – arasaIT Mar 6 at 13:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.