jquery - hard json to pull the values -
my json has structure:
{"0":{"pozycja":0,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}},"1":{"pozycja":1,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}},"2":{"pozycja":2,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}},...}
i try tu pull values 'znizka' , 'autor', loops, no succes. dont know if concernes json.stringify dont have in code(i dont know how put in $.getjson) or strange format of json. thank help!
$.getjson("./baza.json", function(data){ console.log(data); console.log(data.length); (var = 0; < data.length; ++ ){ $.each(data[i], function(index, items) { var pozycja = items.pozycja; var znizka = items.znizka; $('.list').append('<li>' + pozycja + '</li>' + '<li>' + znizka + '</li>'); }); } });
var json={"0":{"pozycja":0,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}},"1":{"pozycja":1,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}},"2":{"pozycja":2,"znizka":{"0":"0.00"},"autor":{"0":"cream software"}}}; var obj=jquery.parsejson(json.stringify(json)); $.each(obj,function(key,value){ console.log(value.pozycja); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Comments
Post a Comment