javascript - get values in pairs from json array -


firstly, json value getting php source:

[{"oid":"2","cid":"107"},{"oid":"4","cid":"98"},{"oid":"4","cid":"99"}] 

after that, want , oid value along corresponding cid value example, oid=2 , cid=107 @ 1 go, oid=4 , cid=98 @ , on. trying use jquery, ajax this.

i have tried many answers this, like: javascript: getting existing keys in json array , loop , key/value pair json array using jquery don't solve problem.

i tried this:

for (var = 0; < l; i++) { var obj = res[i]; (var j in obj) { alert(j); }

but did return key name, again did not work on being used.

so, have array of key/value pairs. loop array, @ each index, log each pair:

var obj = [{"oid":"2","cid":"107"},{"oid":"4","cid":"98"},{"oid":"4","cid":"99"}];  (var = 0; < obj.length; i++) {     console.log("pair " + + ": " + obj[i].oid);     console.log("pair " + + ": " + obj[i].cid); } 

demo: http://jsfiddle.net/stsx2/


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -