Volk3r
Volk3r

Reputation: 23

Javascript jQuery json each

please help for my Code.

var langeJSON = {
    "placeholder":[
    	{ "#iEmail"   :"eMail-Adresse" },
    	{ "#iPasswort": "Passwort" }
    ],
    "text":[
    	{ "#pLoginText"	: "Login..." }
    ]
}

$.each(langeJSON, function(k, v) {
     console.info(k + ' x ' + v);
     $.each(v, function(k1, v1) {
          console.info(k1 + ' - ' + v1);
     })
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Should look like this, this is false

placeholder x [object Object],[object Object]
0 - [object Object]
1 - [object Object]
text x [object Object]
0 - [object Object]

but looks like

placeholder x [object Object],[object Object]
0 - #iEmail
1 - eMail-Adresse
0 - #iPasswort
1 - Passwort
text x [object Object]
0 - pLoginText
1 - Login...

Blackout at the moment, please Help

regards Volker Sorry my English is not Good ;o)

Upvotes: 0

Views: 94

Answers (1)

asimshahiddIT
asimshahiddIT

Reputation: 330

var langeJSON = {
        "placeholder":
        [
            { "#iEmail"     :"eMail-Adresse" },
            { "#iPasswort"  : "Passwort" }
        ],
        "text":
        [
            { "#pLoginText" : "Login..." }
        ]
    }

     $.each(langeJSON, function(k, v) {
            console.info(k + ' x ' + v);
            $.each(v, function(k1, v1) {
              //  console.info(k1 + ' - ' + v1);
               $.each(v1,function(k2,v2)
                      {
                      console.info(k2+':'  +v2);                          });

            });    });

Your missing the one more each function

see the output : http://jsfiddle.net/2ytypjmg/

Upvotes: 1

Related Questions